Open prateekjaizz opened 3 years ago
replace your entire code with this in productActions.js, only for the lesson 13, since I had the problem in lesson 13 same is issue I too faced but when I tried to get the solution it was problem in the casing of Axios, I actually wrote it as axios
import Axios from "axios";
import { PRODUCT_DETAILS_FAIL, PRODUCT_DETAILS_REQUEST, PRODUCT_DETAILS_SUCCESS, PRODUCT_LIST_FAIL, PRODUCT_LIST_REQUEST, PRODUCT_LIST_SUCCESS } from "../constants/productConstants";
export const listProducts = () => async (dispatch) => { dispatch({ type: PRODUCT_LIST_REQUEST, }); try { const { data } = await Axios.get('/api/products'); dispatch({ type: PRODUCT_LIST_SUCCESS, payload: data }) } catch (error) { dispatch({ type: PRODUCT_LIST_FAIL, payload: error.message }) } }
export const detailsProduct = (productId) => async (dispatch) => {
dispatch({ type: PRODUCT_DETAILS_REQUEST, payload: productId });
try {
const { data } = await Axios.get(/api/products/${productId}
);
dispatch({ type: PRODUCT_DETAILS_SUCCESS, payload: data });
} catch (error) {
dispatch({
type: PRODUCT_DETAILS_FAIL,
payload:
error.response && error.response.data.message
? error.response.data.message
: error.message,
});
}
};
Please Help ProductScreen is not working