Nuxt JS Apollo data only available after page refresh

后端 未结 2 1308
北海茫月
北海茫月 2021-01-02 22:26

I am fetching some data using Apollo inside of Nuxt. Somehow, when navigating to that page I get an error of

Cannot read property \'image\' of undefined
         


        
2条回答
  •  孤城傲影
    2021-01-02 22:38

    I think it's only a problem of timing on page load.

    You should either iterate on products, if you have more than one, or have a v-if="product != null" on a product container, that will render only once the data is fetched from GraphQL.

    In that way you'll use the object in your HTML only when it's really fetched and avoid reading properties from undefined.

提交回复
热议问题