I am new to Node.Js. I created an application with Node.JS Express. now I have below folder structure
-core
app.js
-routes
index.js
-views
index.hbs
I want to store a json file into client pc. I want to write below piece of code into hbs file but it is not possible. would you mind explain to me how or where should I write it[in above structre]? It would be nice of you if you can share some link or tutorial that I can read and understand how to handle this kind of situation.
'use strict';
const fs = require('fs');
let data = JSON.stringify(ComponentItem);
fs.writeFileSync('file.json', data, finished);
Please take note that my Json data created in index.hbs. basically, I have the problem how to transfer objects between index.hbs and index.js or I am not sure I am doing right approach!