我使用的是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,
});
}
謝謝您的幫助:)
你是對的,但它不爲我工作...我已經編輯我的代碼在對方的回答 –