axios请求报Uncaught (in promise) Error: Request failed with status code 404
程序员文章站
2022-04-19 17:15:00
...
使用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);
推荐阅读
-
Uncaught (in promise) Error: Request failed with status code 415
-
VUE 登录不上,F12报错Uncaught (in promise) Error: Request failed with status code 404
-
Uncaught (in promise) Error: Request failed with status code 404
-
axios请求报Uncaught (in promise) Error: Request failed with status code 404
-
axios请求报Uncaught (in promise) Error: Request failed with status code 404
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404