I am fairly new to JS and I have a JSON file that I need to send to my server (Express) that I can then parse and use its contents throughout the web app I\'m building.
Another option is to use sendFile
and set the content type header.
app.get('/search', (req, res) => {
res.header("Content-Type",'application/json');
res.sendFile(path.join(__dirname, 'file_name.json'));
})
The code assumes the file is in the same directory as the JS code. This answer explains how this works.