Static GitHub Issues

[1740] Async data in layout?

prev: data context for handlebars template
next: problems with beforeRouteEnter

Hi,

Regarding this:

Make the API call in the asyncData() or fetch() methods of the page component and pass the data as props to the sub components. Server rendering will work fine.

(https://nuxtjs.org/faq/async-data-components#async-data-in-components-)

The point is, I have a component that shall work for every page ; so I call it directly in the layout, so it’s not reloaded at each page load. This composent has a google map, the position / zoom / etc. shouldn't change from one page to another ; it has to be visible and usable at any time, regardless where you are on the site. Basically, it's like an interactive background.

But it contains markers, that are loaded from a rest API, so I need to get them through asyncData ; and I can’t do it directly on the layout too and pass the data as a props…

How should I proceed?

Thanks.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1562">#c1562</a>)</em></sub></div>