Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140131

Node.js HTTP Server- Taking long time to load and is not sending data

$
0
0

I am learning node.js, While using HTTP module i tried to create by own server as per instruction of video tutor but my server is not sending any response at port 3000 and port 8000.

*

const http = require('http');
const server = http.createServer((req, res) => { 
    if(req === '/'){ 
        res.write('Hello world, first program in server using http module');
        res.end();
    }
    if(req === '/api/courses'){
        res.write(json.strigify([1,2,3]));
        res.end();
    }
});
server.listen(8000);
console.log('Listening @port 8000');

*


Viewing all articles
Browse latest Browse all 140131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>