Monday, February 24, 2020

How To Connect Request Post on Node.js Localhost?

Index.js
/*
 *Primary file for the API
 *
 */
 // Dependencies
 const http = require('http');

 const server = http.createServer((req, res) =>{
  if (req.url === '/'){
  res.write('Hello World');
  res.end();
  }
 });

 //The server should respond to all requests with a string
server.listen(3000);

console.log('Listening on port 3000');

Then run on CMD Terminal

node index.js