NuxtJs Cannot read property '_normalized' of undefined

15,027

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

Share:
15,027
Ghyath Darwish
Author by

Ghyath Darwish

Updated on June 05, 2022

Comments

  • Ghyath Darwish
    Ghyath Darwish almost 2 years

    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?

  • Szabó Csaba
    Szabó Csaba about 4 years
    Exactly. Nuxt.js could provide a better error message than this one.
  • Vedmant
    Vedmant almost 4 years
    Yeah, cryptic error, how could anyone understand it without googling.
  • Jakub Záruba
    Jakub Záruba about 2 years
    In my case was problem with undefined url for this.$router.push(...)