Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuxtJs Cannot read property '_normalized' of undefined

this error show when I try to fetch some data in nuxtjs

Cannot read property '_normalized' of undefined

This is my axios request in nuxtjs :

 async asyncData({app}){
        var response = await app.$axios.get('/store/get-services',{params:{id:app.$auth.user.store.id}});
        return {services:response.data.services};
    }

this is a backend controller laravel:

public function store_ads(Request $req){
    if($req->user()->store->id != $req->id){
        abort(403);
    }
    $services = Store::select('id')->with('ads:id,store_id,price,title')->where('id',$req->id)->first();
    return response()->json(['services'=>$services],200);
}

and here is how i fetch them in my template:

<div class="services-list">
                        <h4 class="is-vcentered title has-text-centered has-text-grey-light" v-if="services.ads.length==0">No Services</h4>
                        <ul>
                            <li v-for="service in services.ads" :key="service.id"><nuxt-link>{{service.title}}</nuxt-link></li>
                        </ul>
                    </div>

What is the reason?

like image 289
Ghyath Darwish Avatar asked Jul 06 '19 09:07

Ghyath Darwish


1 Answers

The error was I don't pass to property for <nuxt-link></nuxt-link> and this is what causes this error

like image 66
Ghyath Darwish Avatar answered Sep 22 '22 16:09

Ghyath Darwish