• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

user_action.js / forEach error

20.05.09 20:48 작성 조회수 207

0

Unhandled Rejection (TypeError): response.data.forEach is not a function
(anonymous function)
D:/boilerplate-mern-stack-master/client/src/_actions/user_actions.js:71
68 | // CartItem 들에 해당하는 정보들을  Product Collection에서 가져온후에 
69 | // Quantity 정보를 넣어 준다.
70 | userCart.forEach(cartItem => {
> 71 | response.data.forEach((productDetail, index) => {
| ^ 72 | if (cartItem.id === productDetail._id) {
73 | response.data[index].quantity = cartItem.quantity
74 | }
(anonymous function)
D:/boilerplate-mern-stack-master/client/src/_actions/user_actions.js:70
  67 | .then(response => {
68 | // CartItem 들에 해당하는 정보들을 Product Collection에서 가져온후에
69 | // Quantity 정보를 넣어 준다.
> 70 | userCart.forEach(cartItem => {
| ^ 71 | response.data.forEach((productDetail, index) => {
72 | if (cartItem.id === productDetail._id) {
  73 |  response.data[index].quantity = cartItem.quantity

forEach 에서 에러가 발생 되는데요.

답변 3

·

답변을 작성해보세요.

1

아 넵  제가 하다보니 실수한것들이 많아서 교체한것들이 많이 있었습니다 ㅠㅠ !  수고하세요 ~ ! 

0

skywalk님의 프로필

skywalk

질문자

2020.05.11

제가 다음 강의를 보지 않고 성급해서 그렇죠.

덕분에 많이 알아가고 있습니다. 고맙습니다.

0

skywalk님의 프로필

skywalk

질문자

2020.05.10

해결하였습니다.  소스 파일대로 하였는데  강좌를 다시 보니  send --> json

        response.data.product.forEch 로 바꾸셨네요.

     제가 성급하게 처리 했네요. 수고하세요