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

281
Views
How to reference an external function in nuxt.config?

So basically I'm setting up an app using nuxt, and within the configuration's generate property I need to run a recursive function to build the sites route tree dynamically. The function is rather large so I dont want it to be in the config file itself

Ive tried doing it this way, but think Im way off

import {buildChildRoutes} from 'routeGenerator'

export default {
  generate: {
    routes(){
      var response = await this.$deliveryClient
      .itemsFeedAll()                  
      .toPromise();

      return buildChildRoutes(response)
    })

has anyone done something like this before? i would assume its common and im just missing something in the documentation

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Here's the solution I used that works

This is my code in nuxt.config.js

import getRoutes from './utils/route-generator.js'

const dynamicRoutes = () => {
  return new Promise((resolve) => {
    resolve(getRoutes())
  })
}

export default {
  generate: {
    routes: dynamicRoutes
  }
}
over 4 years ago · Santiago Trujillo Report
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!