当我在下面进行调用时,我想将一个 url 传递给this.props.saveFileInputAnswer
但我得到一个错误,说它Error TypeError: _this.props.saveFileInputAnswer
不是一个函数。saveFileInputAnswer
在父组件中定义并在当前组件中称为道具。
Axios({
url: CLOUDINARY_URL,
method: "POST",
skipAuthorization: true,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: fd
})
.then(response => {
this.getFileUrl(response.data.secure_url);
if (response.statusText === "OK") {
this.setState({ isLoading: false });
//console.log(this.state);
toast("File Upload Successful");
this.props.saveFileInputAnswer(
this.state.fileUrl,
this.props.item._id
);
}
})
.catch(error => {
console.log("Error", error);
});