Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node app

var express = require('express');
var app = express();
var PORT = 3000;
  
app.route('/user')
.get((req, res, next) => {
    res.send('GET request called');
})
.post((req, res, next) => {
res.send('POST request called');
})
.all((req, res, next) => {
res.send('Other requests called');
})
  
app.listen(PORT, function(err){
    if (err) console.log(err);
    console.log("Server listening on PORT", PORT);
});
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #node #app
ADD COMMENT
Topic
Name
9+1 =