[Vuejs]-Pushing onto an array within an array

2👍

this.vehicles is the array and you should find index where the vehicleID is.

const index = this.vehicles.findIndex(v => v.id === vehicleId)
if (index !== -1) {
  this.vehicles[index].photos.push({id: photoId, photoUrl:  photoUrl})
} else {
  // No vehicle found with the vehicleId.
}

Leave a comment