Answer the question
In order to leave comments, you need to log in
How is the request sent to the ssr application?
Hello.
How does sending a request to get data in vuejs (ssr) + node express server work?
I am building an ssr application, indexing is very important and that the data is received before the page is displayed. To work, I took the nuxtjs.org framework and the node express server.
Application structure:
api.site.ru - api without authorization
site.ru - application + express server
On the main site.ru, requests to api.site.ru immediately go:
<template>
...
</template>
<script>
import axios from 'axios'
export default {
async asyncData({ params }) {
console.log('server ajax')
let { data } = await axios.get('http://api.site.ru/companies')
return { companies: data }
}
}
</script>
Answer the question
In order to leave comments, you need to log in
So everything is correct, if you load a tab, then this request will be executed on the server, and on the client it will already follow the links without reloading. In nuxt-link, the "a" tag is inside. asyncData is called on the server to receive data, and on the client when the SPA application is switched.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question