Ich versuche Async-Post-Anfrage zu tun, um meine Daten nur nach Erfolg zu aktualisieren.wie Callback von Post-Anfrage in Reaktion mit Redux, Redux-Thunk und Axios reagieren?
was ich will, ist Versprechen Typ Sache in Aktion Anruf.
this.props.postAction('/event/user/44/post',data)
.then((response) =>{
console.log("Inside callback");
console.log(response);
});
export default connect({postAction})(EventFeed);
hier ist meine Aktion Datei, wo ich mache Post-Anforderung
export const POST_ACTION = 'POST_ACTION';
export function postAction(url,data) {
return function(dispatch) {
axios({
method:'post',
url:API_URL + url,
headers: {'event': 55},
data: data,
})
.then(response => {
dispatch({
type: POST_ACTION,
payload: response.data
});
})
.catch((error) => {
console.log(error);
})
}
}
Aber ich bin nie in Rückruf bekommen.
Jetzt, wie man Rückruf macht, um Daten von der Antwort zu erhalten ???