-4

I'm a beginner in nodejs , i want to insert some values to database by calling an api and i have got api result as ,

[  { 
"rowId": "0",
"group": "RBEIBAN:SMP",
"zoomLevel": "12", 
"latitude": "12.955081", 
"vehicleLocations":
   [ { 
           "rowId": 0,
           "latitude": "12.955081", 
           "longitude": "77.641369",
           "speed": 0, 
     },
     {
                "rowId": 1,
                "latitude": "12.936186",
                "longitude": "77.611698",
                "speed": 0


    } ]
}]

my question is, how can i geI only vehiclelocation from this ? and how can insert into database?

Manjeet Thakur
  • 2,288
  • 1
  • 16
  • 35
user9172381
  • 13
  • 1
  • 3
  • 1
    Possible duplicate of [Access / process (nested) objects, arrays or JSON](https://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json) – baao Jan 04 '18 at 12:58
  • Please spend some time making the question understandable, or even readable. – JHH Jan 04 '18 at 13:31

1 Answers1

0

This answer assumes your response is an object and not a string (if string then use JSON.parse(str) first).

Your response is an array of objects, in the example you have given, there is one object in the array. You want response[0].vehicleLocations

danday74
  • 52,471
  • 49
  • 232
  • 283