Is there an option to get back response from redux-api-middleware inside this function?
dispatch(someAction()).then(() => {
// CONSOLE.LOG RESPONSE HERE
});
Is there an option to get back response from redux-api-middleware inside this function?
dispatch(someAction()).then(() => {
// CONSOLE.LOG RESPONSE HERE
});
Starting with an example from the redux-api-middleware
docs.
const USER_REQUEST = '@@user/USER_REQUEST'
const USER_SUCCESS = '@@user/USER_SUCCESS'
const USER_FAILURE = '@@user/USER_FAILURE'
const getUser = () => ({
[RSAA]: {
endpoint: 'https://hostname/api/users/',
method: 'GET',
headers: { 'Content-Type': 'application/json' },
types: [
USER_REQUEST,
USER_SUCCESS,
USER_FAILURE
]
}
})
If you are using redux-thunk
you can do the following:
dispatch(getUser())
.then((payload) => {
console.log(payload, 'oh hai, payload');
});