試圖調用兩個API的動作。當一個人完成後再打另一個,然後在最後一個傳遞給一個減速器。 看起來像我的getAttending被調用的同時發佈,而不是後發佈完成。我是個新手,認爲我可以一個接一個地打電話給他們。還原thunk調用兩個不同的API請求
export function postDeclined(id){
let post = axios.post(blaBla.com);
let getAttending = axios.get(attending.com);
return (dispatch) => {
post.then(()=>{
getAttending.then(({data})=>{
dispatch({
type: type.NOT_GOING,
payload: data.data
});
});
});
}
}
是什麼postDeclined =>(id)=> async(dispatch)=>是異步的某種方法從await?或者只是包裝鏈方法的名稱。 –
async關鍵字提供了一個返回承諾的函數。 await關鍵字使該行成爲同步調用,並且在承諾解決之前不會繼續。 https://github.com/tc39/ecmascript-asyncawait –
啊確定感謝您的解釋。 –