Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

290
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda