我使用Frontios和Postman的axios和React向REST API服务器查询。结果是不同的。我想同样的事情。
这是一条路线:
localhost:1230/api/v1/users
从我的本地rest API服务器路由,当在最前面时,将localhost更改为数字地址很有趣,我得到了不同的错误。
axios
.get(`127.0.0.1:1230/api/v1/users`)
.then(function (response) {
console.log(response);
})
.catch((e) => console.log(e));
这是错误结果:
Error: "Request failed with status code 404"
createError createError.js:16
settle settle.js:17
handleLoad xhr.js:61
dispatchXhrRequest xhr.js:36
xhrAdapter xhr.js:12
dispatchRequest dispatchRequest.js:52
promise callback*request Axios.js:61
method Axios.js:76
wrap bind.js:9
submitHandler Register.js:14
React 17
unstable_runWithPriority scheduler.development.js:653
React 20
js index.js:10
Webpack 7
将num地址更改为localhost时,接下来出现错误:
**Error: "Network Error"**
createError createError.js:16
handleError xhr.js:83
dispatchXhrRequest xhr.js:80
xhrAdapter xhr.js:12
dispatchRequest dispatchRequest.js:52
promise callback*request Axios.js:61
method Axios.js:76
wrap bind.js:9
submitHandler Register.js:14
React 17
unstable_runWithPriority scheduler.development.js:653
React 20
js index.js:10
Webpack 7
请注意,所有路线均适用于邮递员。
希望您能帮助我,谢谢! o /