-2

Sorry if the title is confusing, I'm confused my self.

So its like this, I get a string from api like this: 'data.data.type'.

And I need to turn it into this response['data]['data]['type'].

Any idea how I can achieve this?

yudhie.z.kurniawan
  • 155
  • 2
  • 2
  • 7

1 Answers1

0

Assuming response is a single object , you can get the value of type like this

var response = {
  data: {
    data: {
      type: "Here is type"
    }
  }
}

console.log(response['data']['data']['type'])
brk
  • 48,835
  • 10
  • 56
  • 78