Testing Your API with Postman

I’ve noticed that most times we start with developing the backend of our projects way before even creating a folder to keep all of frontend content. That can create a couple of challenges along the way. One of them being, how do we make sure that our backend functions as we intended before writing and wiring frontend components to call those functions?

Well, that’s were Postman comes in. Its a lightweight application that’s intended for test our backend POST/DELETE/UPDATE, etc. functions before even a single line of frontend is complete. In this quick tutorial I’ll show you how to work with this tool.

First things first, hop on to their website and download the app and install it. https://www.postman.com/

From there, we fire up our backend server and take note of the URL’s we’ve created. For instance, this is what I have as my functions in this example.

First thing that we want to do is take a look if there’s anything in the database already. We would hit the localhost:PORT/etfs URL with a GET command.

At the moment, the database is empty, so we have the response from the server telling us as such.

Next up, lets try a POST command.

In this particular example, we would select the POST request from the drop down. Select Body as the data we’re sending, and we’ll select it to be formatted as a JSON.

This time, we are greeted with a success message and our entry has been successfully added to the database.

Lets do another GET command to make sure that our data is indeed in the database.

We once again hit the /etfs URL and we see that our data is in the database with an assigned ID.

We will use this ID to try the DELETE request.

We hit the /etf/ID URL and our data is deleted from the database.

That wraps it up for this quick tutorial. We don’t have to wonder anymore or write hasty code to make sure that our backend functions are working as intended, because now we can test them as we go!

Software Engineer