I have a simple express app, and I am trying to listen to app.get() router from JS file but I am getting Error here:
fetch('/').then(function(response) {
return response.json();
}).then(function(data) {
console.log(data);
}).catch(function() {
console.log("Error");
});
app.js
app.get('/',(req,res)){
// some data fetched from api
res.send(data)
}
How can i use fetch to get results from get request from pure JS file? TIA!