首页 > 解决方案 > 无法从我的前端使用 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);
  });

标签: node.jsreactjsaxios

解决方案


推荐阅读