Successfully added
JavaScript
by Patrik
Axios Library
Axios is a popular JavaScript library that simplifies HTTP requests, making it easy for beginners to interact with web services and APIs. With a simple and intuitive syntax, Axios provides a clean way to handle asynchronous tasks in web development. Whether fetching data or sending requests, Axios streamlines the process, enhancing the efficiency of frontend development.
...see more
Make Axios send cookies in its requests automatically.
You can use the withCredentials
property.
axios.get(BASE_URL + '/todos', { withCredentials: true });
Also it is possible to force credentials to every Axios requests
axios.defaults.withCredentials = true
Or using credentials for some of the Axios requests as the following code
const instance = axios.create({
withCredentials: true,
baseURL: BASE_URL
})
instance.get('/todos')
Referenced in:
Comments