divanov11 / proshop_django

407 stars 430 forks source link

Can't get "order._id" from PlaceOrderScreen.js #20

Closed 2sdarko closed 2 years ago

2sdarko commented 2 years ago

I'm stuck at section 52, in PlaceOrderScreen. Keep getting ff error:

TypeError: Cannot read properties of undefined (reading '_id'), from this segment:

========================== useEffect(() => { if (success) { history.push(/order/${order._id}) dispatch({ type: ORDER_CREATE_RESET }) } },[success, history])

Please help

2sdarko commented 2 years ago

Below is full error msg, pls can someone help

TypeError: Cannot read properties of undefined (reading '_id') (anonymous function) src/screens/PlaceOrderScreen.js:31 28 | 29 | useEffect(() => { 30 | if (success) {

31 | history.push(/order/${order._id}) | ^ 32 | dispatch({ type: ORDER_CREATE_RESET }) 33 | } 34 | },[success, history]) View compiled ▶ 22 stack frames were collapsed. (anonymous function) src/actions/orderActions.js:42 39 | payload: data 40 | }) 41 | 42 | dispatch({ | ^ 43 | type: CART_CLEAR_ITEMS, 44 | payload: data 45 | })