[Vuejs]-Nuxt: Import a js depending on i18n

0๐Ÿ‘

I have found a solutiond and it is simple.

I was missing to add the app and then using it inside asuncData (on that context this. doesnt do anything)

async asyncData({ route, app, error }) {
    try {
      const entry = await import(
        `~/assets/data/${app.i18n.locale}/portafolio/${route.params.work}.js`)
      return { entry: entry.default || entry }
    } catch (error_) {
      error({
        message: 'Not Found',
        statusCode: 404,
      })
    }
    return {}
  },

Leave a comment