Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'image' of undefined #91

Open
prateekjaizz opened this issue May 19, 2021 · 1 comment
Open

TypeError: Cannot read property 'image' of undefined #91

prateekjaizz opened this issue May 19, 2021 · 1 comment

Comments

@prateekjaizz
Copy link

Please Help ProductScreen is not working

@sharan-jain
Copy link

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,
});
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants