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

 

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM