我使用的是Axios和React.js。 我想在webservice的响应之后调用一个函数。但它不工作,这是我的代码:Axios:响应后调用函数
public onValidateRenammeNature =() => { // bouton valider, renomme la nature
let id
let newName
console.log("this.state.myNature.id : " + this.state.myNature.id)
id = this.state.myNature.id
newName = this.refs.nature.getValue()
axios.post('/UpdateNature', {
id: id,
name: newName
}).then(
//here I want to call this function after the webservice is executed, but I don't know how can I do that
this.getAllNaturesFromData()
)
this.setState({
openRenammeNature: false,
});
}
谢谢您的帮助:)
你是对的,但它不为我工作...我已经编辑我的代码在对方的回答 –