Axios 抛出“内部服务器 500”错误

时间:2021-06-15 18:25:19

标签: javascript reactjs

所以。我一直在尝试修复我的 web 应用程序中的错误。当发送 axios POST 请求时,数据会在片刻后保存。 此外,我将范围缩小到 API 抛出“500(内部服务器错误)”的原因,但不知何故数据仍然得到更新(片刻之后)。

我的代码到这里是这样的:

    changeStatus() {
        const { match: { params } } = this.props;

        let assigned = this.state.projres && this.state.projres.assign
        let fd = new FormData();
        fd.append("projectId", params.pid);
        fd.append("status", "Completed");
        fd.append("assignedToId", assigned);
        axios({
            method: 'post',
            url: `${url}/project/accepted`,
            data: fd,
        })
        .then((response) => {console.log("here is the resp" + fd)},(error) => {console.log("Error for it is" + error)})
           .then(this.props.actions.getDetails(params.pid)
            ).then(console.log("Here it all ends!"))}

在我的控制台中,我得到的数据是按顺序的

Here it all ends!
POST http://localhost:8000/project/accepted 500 (Internal Server Error)
here is the resp[object FormData]

上面的控制台响应看起来也很奇怪,因为它没有使 .then() 有用。

请帮忙,代码中可能有什么错误? PS:我查了很多其他的API和post数据表,都是正确的。在 Postman 中也尝试过,它在那里也能正常工作。

0 个答案:

没有答案