0
我試圖在axios調用它不通過之後將值傳遞給URL參數。下面的代碼說明我的問題:在axios中傳遞URL參數與react-redux
export function fetchUser(id) {
console.log(id) // works
return function(dispatch, id) {
console.log(id) // does not work
axios.get("https://jsonplaceholder.typicode.com/users?id=" + id)
.then((response) => {
dispatch({type: "FETCH_USER_FULFILLED", payload: response.data})
})
.catch((err) => {
dispatch({type: "FETCH_USER_REJECTED", payload: err})
})
}
}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures –
你確定你是這樣激發了內部函數:fetchUser(id)(dispatch,id)? –