Need to map array of objects. Keep getting “Cannot read property ‘map’ of undefined”.
survey.questions.map((question)=>{ console.log('the question: ',question); })
survey json looks something like this…
[{
"questions": [{ "name": 0, }, { "name": 1, }, { "name": 3, }, }]
}]
survey.questions is null.
put in a print statement and you’ll see that.
When the state renders before the api call is made survey.questions might be an empty object. you can do this instead {survey.questions && survey.questions.map((question)=> { console.log('thequestion: ', question); })
also you can debug with console.log