Answer the question
In order to leave comments, you need to log in
How to dispatch data from the API to the storage right away?
Hello everyone, I can’t understand how to correctly dispatch data from the API to the storage
There is an input and there is an API Task
Substitute the value of the input in the API (this is a weather application) and dispatch to the storage
Answer the question
In order to leave comments, you need to log in
You can use redux-thunk related
article
An abstract example of an asynchronous action with a request:
const fetchUsers = params => async dispatch => {
try {
const data = await Api.fetchUsers(params);
dispatch(fetchUsersSuccess(data));
} catch (e) {
dispatch(fetchUsersFail(e));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question