0

I have a frontend in NuxtJs. I want to list out all the PDFS stored under the static folder and make a dynamic link to open those documents in the browser as a separate window. So I want to get the list of all the files of specific folder.

  • Vue.js questions are highly version specific and should always be tagged with [vuejs2] or [vuejs3] in addition to this tag. – Bravo Jun 06 '22 at 07:37

1 Answers1

0

Nuxt.config.js uses fs module as default loader. we can add this snippet of code to the Nuxt.config.js file and store the response to the env variable so that it can be used anywhere.

const fs = require('fs')
// To read Static Files
const files = fs.readdirSync('./static/pdfs')
process.env.STATIC_REFERRAL_DOCS = files