原生ajax请求
let xhr = new XMLHttpRequest();
xhr.open('Post','xxxxxxurl');
xhr.send();
xhr.onReadystatechange = function() {
if(xhr.readystate==4){
if(xhr.state>200&&xhr.state<300){
console.log(response)
}
}
}
响应拦截器中返回的数据request中,包含response和responseText,得到的是字符串
想要转换成object格式;
可以用eval()
eval("("+res.request.responseText+")")