[Vuejs]-How to access to response data index by javascript

0👍

Given that the response of the API call was an array as per the screenshot and comment:

[
  {
  "id":1,
  "firstname":"Neng",
  "lastname":"vang",
  "email":"nengvang@gmail.com",
  "password":"1234"
  }
]

The question was asking to retrieve the firstname and lastname, so the solution was to use the index 0 on the resulting array as follows:

this.login_result[0].firstname and this.login_result[0].lastname

Leave a comment