Answer the question
In order to leave comments, you need to log in
Why is the function not called on the 2nd request to the server?
Good time!
I send a request to the server to change the data
axios({
method:'post',
url:`some url`,
data: params_string+'&signature='+md5(params_string)
}).then(response => {
onLoadPage();
dispatch(editTask(response.data));
});
onLoadPage();which should trigger the second request, the function is called, but the request is not called for some reason, why is that?
export function onLoadPage(sortField = 'id', sortDirection = 'asc', page = 1) {
// здесь работает
return (dispatch) => {
//а здесь уже вызова нет
axios.get('some url',
{
params: {
sort_field: sortField,
sort_direction: sortDirection,
page: page
}
}
).then(response => {
dispatch(loadTaskList(response.data));
});
}
}
Answer the question
In order to leave comments, you need to log in
Because onLoadPage returns a function that no one calls, it should be like this:onLoadPage()(dispatch);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question