Answer the question
In order to leave comments, you need to log in
How to get API data and put it in storage using redux-thunk?
Stuck on the redux-thunk stage
I want to put the data from the API into the store. Began to deal with redux-thunk. But something is still difficult.
Explain with a simple example what it is and what it is eaten with)
Answer the question
In order to leave comments, you need to log in
export const endWorkingDay = () => (dispatch, getState) => {
return axios.post(`${API_ROOT}/api/Account/EndWork?date=${endDate}&tradePointId=${id}&lat=${currentLat}&long=${currentLong}`,
null,
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json;charset=UTF-8",
},
}
)
.then(
response => {
if (response.status === 200) {
dispatch({
type: SET_END_WORK_DATA,
payload: {
endWorkData: {
tradePointId: id,
lat: currentLat,
long: currentLong,
date: dateformat(new Date(), "yyyy-mm-dd"),
synced: true,
},
},
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question