要确保Axios在请求之间发送之前设置的cookie,需要通过设置axios.defaults.withCredentials为true来使Axios包含cookie。例如:
axios.defaults.withCredentials = true;
axios.get('/api/data') .then(response => { console.log(response.data); }) .catch(error => { console.log(error); });
在这个例子中,Axios会在请求之间发送之前保存cookie,并在每个请求中发送它们。