A
A
Adelina Turcan2019-02-15 04:33:29
JavaScript
Adelina Turcan, 2019-02-15 04:33:29

What is the correct way to make backend requests in nuxt.js?

How to create requests from components (components) to the API in the Nuxt.js framework?
The backend works over the http protocol.
If you can, show an example with storebut you can use without it.
I tried to use nuxtServerInit it and the request is made, I get the data, but I can’t further transfer them from nuxtServerInitthe component to show them. I guess that's nuxtServerInitnot what it was designed for.
AsyncDataonly works with components from pages.
You need to get the categories and send them to the sidebar.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2019-05-19
@IgorPI

nuxtServerInit is not designed to load data, especially in the Page component
AsyncData will merge with data in the page (page)
fetch - just for loading, what you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question