0

Sample JSON

 "data": {
    "title": "test2",
    "selectedBoardData": {
        "boardId": "1070",
        "boardTitle": "My New Board",
        "createdAt": 1526385544606,
        "modifiedAt": 1526390958854,
        "spcxId": "1070",
        "widgetList": [
            {
                "widgetId": "3b728bae-1c5a-4f48-a0c7-f9c8f0b13199",
                "widgetName": "widget 0",
                "widgetType": "venn",
                "leftTarget": "MALE",
                "rightTarget": "HHMALE",
                "leftTargetValue": 117112,
                "rightTargetValue": 160432,
                "position": {
                    "row": 0,
                    "col": 0
                }
            }
        ]
    }
}

Trying to iterate

getting data for action.payload.selectedBoardData.widgetList.map but later i am not able to get data.

please let me if there is any error.

Not able find out what is wrong in this.

code

  const storyboardlist = action.payload.selectedBoardData.widgetList.map(widgetDataList => ({
    leftTarget: widgetDataList.leftTarget,
    rightTarget: widgetDataList.rightTarget,
    leftTargetValue: widgetDataList.leftTargetValue,
    rightTargetValue: widgetDataList.rightTargetValue,
    position: widgetDataList.position,
    //})),
  }));
  return { ...state, boardList: storyboardlist };
15
  • Sample object first key is data not selectedBoardData Commented May 31, 2018 at 15:29
  • @lomboboo you mean i need to add 'data' also Commented May 31, 2018 at 15:31
  • yes, action.payload is your sample object that starts with data key Commented May 31, 2018 at 15:32
  • @lomboboo still i am not able to get Commented May 31, 2018 at 15:38
  • Just debug what do you get from action.payload and paste console.log here Commented May 31, 2018 at 15:39

1 Answer 1

1

Your .map() code is fine.

It's just the way you are getting the array, try to console.log() these references to find out: action.payload.widgetList, action.payload.selectedBoardData.widgetList

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.