Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maltekiefer's avatar

Vue did not receive all data from api

Good morning,

I have the following relationship in the database:

class Address extends Model
{
....
    public function addressestimate()
    {
        return $this->hasMany('\App\Models\AddressEstimate', 'addressesid', 'id');
    }

When retrieving the data, I output you as follows:

public function show($id, $delegatesid)
{
    $data = Address::with('files')->with('addressestimate')->with('salutation')->with('country')->where('id', $id)->where('delegatesid', $delegatesid)->get();

    return response()->json($data);
}

When I enter the API call accordingly in the browser, all the data is displayed to me, including the 3 elements in the addressestimate. If I make the call with Vue, everything is shown in the console except addressestimate which is always empty. I have this with 3 different browsers and I don't understand the problem.

All other relations will also display your content. Here is the call in Vue

this.$http.get('/addresses/' + this.$route.params.salesleadid + '/delegates/' + userInfo.user.delegatesid)
    .then(function (response) {
            console.log(response)

And this is the route

Route::get('/addresses/{id}/delegates/{delegatesid}', [AddressesController::class, 'show'])->where('id', '[0-9]+')->where('delegatesid', '[0-9]+');

0 likes
2 replies
kossa's avatar

Can you check the the network tab in debug bar and filter xhr, and make a screen shot ?

By the way you can replace your show method by :

public function show($id, $delegatesid)
{
    return Address::query()
                ->with('files', 'addressestimate', 'salutation', 'country')
                ->where('id', $id)
                ->where('delegatesid', $delegatesid)
                ->get();
}
1 like
maltekiefer's avatar

Here you see the console

https://i.ibb.co/wYdRNtN/image.png

There you see 4 entries but the data is empty And here is the requested screen

https://i.ibb.co/n8htJ4G/image.png

Please or to participate in this conversation.