Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
Nuxtjs, Express call database from asyncdata

I wrote an application using nuxtjs and I'm using SSR. The approach of fetching data from asyncdata function on server I've seen online always suggest that I make that API request from the server to itself. eg

export default {
async asyncData({ params, $http }) {
  const post = await $http.$get(`www.myserver.com/api/resource`)
  return { post }
}}

I know this will work but for performance and latency issues, I see no reason why we should route the internet twice just to render one page.

So my question is, how can I manually forward a request to my API routes without hitting the internet again in express?

One Approach is importing my database modules to this vue file and doing all dependency injection stuff. This seems inappropriate though.

What I want to do is something like

import apimodule from './apimodule.js'
const data = apimodule.handle(request)
return {data}

Thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda