F
F
fierfoxik2019-01-29 13:57:34
JavaScript
fierfoxik, 2019-01-29 13:57:34

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));
        });

After executing a successful promise, I try to call the function
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

1 answer(s)
D
Dmitry Belyaev, 2019-01-29
@fierfoxik

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 question

Ask a Question

731 491 924 answers to any question