我正在使用 Node js Rest API。在身份验证过程中,api 返回一个访问 token 。我需要将访问 token 添加到来自公共(public)位置的每个请求。
最佳答案
您可以使用http interceptor
代码如下
$httpProvider.interceptors.push(function($q, $cookies) {
return {
'request': function(config) {
config.headers['Token'] = $cookies.loginTokenCookie;
return config;
}
};
});
关于angularjs - 将访问 token 添加到 Angular js 中的每个请求 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35836571/