W
W
WAYNEDEV2020-09-11 13:02:19
Vue.js
WAYNEDEV, 2020-09-11 13:02:19

Correct way to process data in nuxt?

Hello!

Usually I make requests to asyncData, and process the data there. Each processing = a loop that puts flags in the array objects.
But now there are about 15 requests on the page and the page starts to delay loading.

Tell me, will it help if the data is received in asyncData, and the data processing takes place in the created hook? Or what is the best way?

Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
RokeAlvo, 2020-09-12
@RokeAlvo

No, it won't help, it's not about where this data is processed.
general recommendation: if the next request does not depend on the previous one, do them at the same time
i.e. Here's how NOT to do it:

async fetch () {
  this.users = await this.$axios.get()
  this.otherData = await this.$axios.get()
}

instead do this:
async fetch() {
  const req = [
    this.$axios.get('/users')
    this.$axios.get('/otherData')
  ]
  const [users, otherData] = await Promise.all(req)
  this.users = users.data
  this.otherData = otherData.data
}

A
Aetae, 2020-09-12
@Aetae

RokeAlvo 's advice is useful, but the browser also has a limit on the number of concurrent requests, so 14 is a lot. Think about how to combine these requests. I don't think they all go to completely different places for completely different data.
We will have to move away from direct requests by url and write an aggregator / cacher through which to access the data, but this is inevitable.

T
TyzhSysAdmin, 2015-09-18
@POS_troi

You set up connections to dsl on the tick, raise vpn, dstnat-ohm, we forward all requests to the "such and such" port to the server's IP.
And well, you set up DynDns, or you have a native Tikovsky one, it seems to have gone from the 6th version.

R
Ruslan Fedoseev, 2015-09-18
@martin74ua

Can you provide more details on the task? Where are the modems, where is the Mikrotik, where is the database server, from where should I configure the vpn?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question