DEV Community

loizenai
loizenai

Posted on

Node.js/Express RestAPIs Example - POST/GET/PUT/DELETE requests

https://grokonez.com/node-js/nodejs-restapis-how-to-create-nodejs-express-restapis-post-get-put-delete-requests

Node.js/Express RestAPIs Example - POST/GET/PUT/DELETE requests

In the tutorial, we're gonna look at way to create NodeJs/Express RestAPIs with Post/Get/Put/Delete requests.

Related posts:

Overview

Demo

Goal

We create a NodeJs/Express RestAPIs project that has structure as below:

nodejs express - restapis - project structure


/nodejs-restapi
    /app
        /controllers
            customer.controller.js
        /routes
            customer.routes.js
    /node-modules
    package.json
    package-lock.json
    server.js

The project create a set of Rest-APIs for POST/GET/UPDATE/DELETE APIs:

  • /api/customers - GET all customers
  • /api/customers/:id - GET a customer by Id
  • '/api/customers - POST a customer
  • /api/customers/update/:id - UPDATE a customer by Id
  • /api/customers/delete/:id - DELETE a customer by Id

Setup NodeJs/Express project

More at:

https://grokonez.com/node-js/nodejs-restapis-how-to-create-nodejs-express-restapis-post-get-put-delete-requests

Top comments (0)