node.js - 无法从我的前端使用 axios 发送表单数据。出现网络错误。但是当我试图从邮递员那里打后端时,它工作正常
问题描述
我已经写在下面了。我尝试不添加标题和标题。我已经在我支持的中间件中添加了标题。但我仍然收到网络错误。任何的意见都将会有帮助
this.data = {
name: this.state.name,
email: this.state.email,
username: this.state.username,
password: this.state.password,
};
this.headers = {
'Content-Type': 'application/json; charset=utf-8',
Accept: 'application/json',
};
Axios.post('http://localhost:8080/api/auth/signup', this.data, this.headers)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
解决方案
推荐阅读
- sql - 有谁知道 SQL 查询来获取多列的 SUM?
- macos - 我可以检测来宾是否正在使用 OSX 机器吗?
- java - 使用 getConstructor() 检查构造函数不带参数
- c# - 如何检测鼠标是否停止在 Unity 中移动
- java - CSS未在spring boot应用程序中加载
- ruby-on-rails - 无法访问最新版本 GitHub gem 中的功能
- android - 是否可以在 Nativescript 中使用矢量可绘制对象作为图像源?
- javascript - HtmlUnit 执行 Javascript 后如何获取页面
- c# - DrawArc 对圆形有效,但对椭圆无效
- javascript - 在异步调用中使用 Promise 进行递归