Hello I'm trying to read all the files' file paths in a folder and feed that into an Html file using iteration. I'm using Vue and Node to achieve this but I keep getting vue.js:597 [Vue warn]: Error in beforeCreate hook: "ReferenceError: require is not defined"
. Below is my code for the Javascript in question.
function init() {
new Vue({
el: '#imgVue',
data: {
basePath: 'images/projects/',
collectionImg: []
},
beforeCreate() {
const fs = require('fs')
const imageFolder = 'images/projects'
fs.readdir(imageFolder, (err, files) => {
files.forEach(file => {
collectionImg.push(file)
})
})
}
})
}