[Vuejs]-Vue-js call object with special id

0👍

So the API returns you multiple patients’s data while you’re asking it for just one exact patient. There must be something wrong with the API with the filtering in first place. So you can filter your data on the client side, in your MedCard.vue component. First this component have to show data for one patient only, so the v-for="med_record in med_records" is not needed. Your med_records property can become just an object not an array:

data() {
        return {
            med_record: {},
        }
}

And in the success resolve method of your API call you can filter only the data you need and store it in med_record

success: (response) => {
                    this.med_records = response.data.data.find((patient)=> { return patient.id === this.id})
                }

If you want to store all the data in the med_records, then you can create computed property and apply the same filtering there.

I hope this helps.

Leave a comment