Currently I am using
app.get('/prices/all', function (req, res) {
fs.readFile( __dirname + "/" + "data.json", 'utf8', function (err, data) {
res.set({ 'content-type': 'application/json; charset=utf-8' })
res.end( data );
});
})
which all works great however I want to send an error json response if a user attempts to use any other url e.g. /prices on its own. e.g.:
{status:"failed", error:"wrong get attempt"}
this is hosted on a sub-domain so all links for api.sitename.com/# need to be removed but /prices/all
See Question&Answers more detail:os