fe-interview
fe-interview copied to clipboard
[js] 第320天 在axios中怎样添加授权验证?
- 在创建axios实例后
var instance = axios.create({ baseURL: 'https://api.example.com' }); instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
可以在headers请求头里添加token config.headers['Authorization'] = 'Bearer ' + token