Hello am currently using redux toolkit in my project & i have encountered a problem when i was fetching data from back-end.The action type is success, the data is stored in the action's payload successfully and it keeps returning an empty array 'products', yet when i run it through postman and it returns data. I can't seem to figure the problem. Here is the code for the reducer
PostReducer.js
export const listArticlesReducer = (
state = { products:[], loading: false, error: false},
{ type, payload }
) => {
switch (type) {
case "RETREIVING_START":
return {...state, loading: true};
case "RETREIVING_SUCCESS":
return {...state, products: payload, loading: false};
case "RETREIVING_FAIL":
return {...state, loading: false, error: payload };
default:
return state;
}
};
Could you please tell me where is the problem ?