正如标题所述,我需要在 axios 调用函数之后刷新页面,但不是在收到承诺之前。函数触发后页面当前正在刷新,但未收到承诺。我想要做的是向 api 提交一篇博客文章,当我在最后添加 preventDefault 函数时,一切正常。
这里的功能:
handleSubmit(event){
axios.post("https://saulvegablog.devcamp.space/portfolio/portfolio_blogs", this.buildForm(), {withCredentials:true})
.then(response => {
this.props.handleSuccessfullFormSubmission(response.data);
}).catch(error => {
console.log("handlesubmit error for blog ", error)
})
event.preventDefault();
}
Run Code Online (Sandbox Code Playgroud)