Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!