Node.js Creating API's with Node.js GET api using Express

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Node.js apis can be easily constructed in Express web framework.

Following example creates a simple GET api for listing all users.

Example

var express = require('express');   
var app = express();

var users =[{
        id: 1,
        name: "John Doe",
        age : 23,
        email: "[email protected]"
    }];

// GET /api/users
app.get('/api/users', function(req, res){
    return res.json(users);    //return response as JSON
});

app.listen('3000', function(){
    console.log('Server listening on port 3000');
});


Got any Node.js Question?