Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Vue: lost object attribute after put response.data to local aray

I have API that returns json objects like this:

[
{"id":3,"delivery_from":"bsl","task_id":410169,"unit_job_id":224128,"completed_at":null,"deleted_at":null,"created_at":"2021-10-20T13:24:07.000000Z"},
{"id":3,"delivery_from":"bsl","task_id":410169,"unit_job_id":224128,"completed_at":null,"deleted_at":null,"created_at":"2021-10-20T13:24:07.000000Z"}
]

When i print response.data in browser console, I see that all objects params are ok, but when I put response.data to local array deliveryJobs: [], then I see that task_id attribute is undefined. What wrong I am doing?

<script>
  import AxiosHandler from './mixins/AxiosHandler'
  import axios from 'axios'

  export default {
    i18n: window.i18n,
    mixins: [
      AxiosHandler,
    ],
    props: {
      unitJobId: Number,
      unitId: Number,
      taskId: Number
    },
    data: () => ({
      deliveryJobs: [],
      unitJob: {}
    }),
    async created () {
      this.getDeliveryJobs()
    },
    methods: {
      getDeliveryJobs () {
        axios
        .get(`/api/v1/unitjobdelivery`, { params : { unit_job_id : this.unitJobId } })
        .then(response => {
          this.deliveryJobs = response.data
        })
        .catch(this.handleAxiosError)
      }
    }
  }
</script>

Undefined task_id

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Solution found. My API was returning laravel collection instead of array. I changed return to array and now all works fine.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda