使用axios处理请求时,出现的问题解决
当url是远程接口链接时,会报404的错误:
Uncaught (in promise) Error: Request failed with status code 404
解决方法:
var instance = axios.create({ headers: {'content-type': 'application/x-www-form-urlencoded'} });
instance.post(`url`, params).then(res => res.data);
后台接收不到传入参数解决方法:
var qs=require('qs');
var instance = axios.create({ headers: {'content-type': 'application/x-www-form-urlencoded'} });
instance.post(`url`, qs.stringify(params)).then(res => res.data);