I am trying to show the JSON data into browser. When I type following code and start the server the data gets displayed in console.
const gamesDataa = gamesData(undefined, (data) => {
console.log(data)
})
But when I try to fetch the data. like below. It shows undefined. How to get that data into an variable? So that I can pass it through handlebars and display in the browser?
const gamesDataa = gamesData(undefined, (data) => {
return data
})
console.log(gamesDataa)
I also tried the following code. But it's sending [Object, Object] to the browser when I fetch newData in the handlebar file named /json.
app.get('/json', (req, res) => {
gamesData(undefined, (data) => {
res.render('json', {
newData: data
})
})
})