DEV Community

Leela Khadka
Leela Khadka

Posted on • Updated on

CRUD operations using Postman.

Hello! Welcome to my first post, and thank you for checking out my blog.

There are multiple ways to process data using Http, but today we will be covering to perform http requests via postman.

Image description

Steps:

  1. Download postman from https://www.postman.com/downloads/
  2. Prepare a fake REST API by following steps below or use one if you have a REST API already available
    • create a project in vscode (New Folder)
    • Install json-server using (npm install json-server) this will give a fake REST API server for to work with if you don't have a API
    • create a file called package.json with contents below Image description
    • create a file called db.json with contents below Image description
    • now we need to run the json server to start the fake REST API (json-server --watch db.json) from the directory where the db.json is saved.
    • once you execute json-server --watch db.json a REST API should be available at http://localhost:3000/animals

CRUD operations using Postman

  • Create (POST Request): To add a new animal to database, open postman then click New -> HTTP Request, it will prompt with Untitled Request Tab. Use request below and click Send.

  • Read (GET Request): To fetch an animal response using its id from database, open postman then click New -> HTTP Request, it will prompt with Untitled Request Tab. Use request below and click Send.

  • Update (Update Request): To update a existing animal, open postman then click New -> HTTP Request, it will prompt with Untitled Request Tab. use request below and click Send.

  • Delete (DELETE Request): To delete animal by id open postman then click New -> HTTP Request, it will prompt with Untitled Request Tab. Use request below and click Send.

Top comments (0)