axios请求报Uncaught (in promise) Error: Request failed with status code 404

使用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); 

 

  

posted @ 2018-09-06 16:12  _nicest  阅读(70137)  评论(0编辑  收藏  举报