无效的POST请求

时间:2018-09-22 13:27:11

标签: reactjs post axios

考虑以下代码:

submit = (event) => {
    //console.log(this.state);
    axios({
      method: 'post',
      url: 'https://uxcandy.com/~shapoval/test-task-backend/create?developer=Agarkova',
      crossDomain: true,
      headers : {
        'Content-Type': 'multipart/form-data'
      },
      processData: false,
      data: {
        username : "User",
        email: this.state.user.email,
        password : this.state.user.password,
        notes : this.state.user.notes,
        task : this.state.user.task,
        file : this.state.user.file
        },
      config: { headers: {'Content-Type': 'multipart/form-data' },
        onUploadProgress : progressEvent => {
          console.log('Upload Progress:' + Math.round(progressEvent.loaded / progressEvent.total * 100) + '%')
        }
      }
    }).then(function (response) {
      //handle success
      console.log(response.data);
  })
  .catch(function (response) {
      //handle error
      console.log(response);
  });
  }

我收到一条错误消息:

{status: "error", message: {…}}message: {username: "Field is requeired", email: "Field is requeired", text: "Field is requeired", image: "No image uploaded"} status: "error"__proto__: Object

0 个答案:

没有答案