0

I am using map function to get "id" from multiple records of single JSON response.But I am having error like "e.map is not a function"

enter image description here

2

1 Answer 1

0

map only works on variables which has been declared like following or having data like following

let e = [] //or
let e = [1,2,4,,5,6]

if you have you value in e as obj like

e = {} //or
e = {id: 1, name: 'example"}

You need to iterate it using 'for in'

for(var key in e){ console.log(e[key]) }

Make sure first what kind of data you have stored in e.

1
  • 1
    It Was an API response that I want to map....I simply parse it into JSOn by JSON.parse(<APi response >) and it worked.....
    – Palak
    Feb 16, 2020 at 8:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.