Axios可以将凭据选项设置为“包括”

时间:2019-04-30 11:14:36

标签: node.js vue.js npm axios

我正在尝试将客户端上的Axios用于运行在不同端口上的服务器。我必须设置凭据='include';因为我的cookie中有身份验证令牌。但是,Axios似乎没有该选项。

我尝试使用凭据= true,但我需要的是凭据='include'。确实没有用。

我一直在使用Vue.js的http模块,拦截器看起来像

Vue.http.interceptors.push((request, next) => {
request.credentials = 'include';
next()})

,这很好。但是我现在需要为Axios做完全相同的事情,而且我不知道该怎么做。

我尝试过,

axios.interceptors.request.use(function(config){
config.credentials = true;
return config;}, function(error){})

但是没有用。

非常感谢您的帮助!

0 个答案:

没有答案