以下のAltアクションコードで、addCharacterの成功後にgetCharacters()を呼び出すにはどうすればよいですか?基本的に私は新しいレコードをデータベースに保存した後に文字のリストをリフレッシュしようとしています。React Js ALT - 他の関数の成功時に関数を呼び出す
getCharacters() {
requestPromise('http://localhost:3100/api/characters')
.then((res) => {
console.log("Getting Characters");
var opdata = JSON.parse(res);
this.actions.getCharactersSuccess(opdata.characters);
}).catch((err) => {
console.log('error:', err);
this.actions.getCharactersFail(err)
})
}
addCharacter(data) {
var options = {
method: 'POST',
uri: 'http://localhost:3100/api/characters/add/',
json: true,
body: {
name: data.charName,
allegiance: data.charAllegiance,
},
};
requestPromise(options)
.then((res) => {
// How can I recall getCharacters() from here
}).catch((err) => {
console.log('error:', err);
})
}
STORE
getCharactersSuccess(res) {
this.setState({
characters: res
})
}
チェックこの1、役に立つかもしれません。http://stackoverflow.com/questions/34370957/bluebird-warning-a-promise-was-created-in-a-handler-but-was-not-返信from私は –