Here is my code:
const express= require('express');
var app=express();
app.get('/',(req,res)=>{
console.log('Sending data');
res.send('Hello Express!');
console.log('Data sent');
});
const port = process.env.port || 8080;
app.listen(port,()=>{
console.log('Listening to port ',port);
});
Operating system is Windows 10 and node version is 10.11.0 and express version is 4.14.0 Code Editor is VS Code
On running the localhost:8080/,the prompt is showing:
Listening to port 8080 Sending data Data sent Sending data Data sent Sending data Data sent
and then the page shows: This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE
I have tried port 3000 and still same error.I have also tried Internet Explorer. I think either express not sending data or browser is unable to receive.