My app is running on port 3000. and i want to fetch data in a redux action from backend running on port 5000.
The data is not being fetched from backend. I'm getting not defined error.
frontend/redux/categoryAction.js:
export const listCategories = () => async (dispatch) => {
try {
dispatch({ type: 'CATEGORY_LIST_REQUEST' })
const { data } = await fetch('http://localhost:5000/api/categories')
dispatch({
type: 'CATEGORY_LIST_SUCCESS',
payload: data
})
} catch (error) {
dispatch({
type: 'CATEGORY_LIST_FAIL',
payload: error.response && error.response.data.message
? error.response.data.message : error.message
})
}
}