axios请求携带cookie

1 getAll(id){
2 axios.defaults.withCredentials=true;
3     axios.get(`$请求地址}`)
4  .then(result => {
5       console.info( result );
6 }).catch(error => {
7       console.log('错误', error)
8   });
9 }
XMLHttpRequest.withCredentials 有什么用?
跨域请求是否提供凭据信息(cookie、HTTP认证及客户端SSL证明等)
也可以简单的理解为,当前请求为跨域类型时是否在请求中协带cookie。
 
注意:前端设置credentials属性后,要通知后端做允许,否则请求失败,状态200黑色
原文地址:https://www.cnblogs.com/qihang0/p/12555001.html