Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!