DEV Community

Cover image for Environments variables in Postman
Joel Aldair Chan Tec
Joel Aldair Chan Tec

Posted on

Environments variables in Postman

hello everyone, first of all , this is my first post in dev.to and I'm going to share you some of my little knowledge and my experience as a junior Backend developer.
today I'm going to talk about one tool that's is usefull named POSTMAN.
what is postman?
postman is a tool used to make REST API calls,however exist others tools like : insomia but is almost the same , these tools are very usefull.
how to use postman?
it is used to requests . you must have the URL and you should know what type of request you will do , only you must put the URL in the field named URL and make the request that the REST API is holding on
Example:
Alt Text

the previous image show us how the make a basic call using postman without using environment variables and below I will show you how to do it using environment variables.

Step One

once being in post, find the button manage environment
Alt Text

step two

now is time to create an environment
Alt Text
when we create an environment then we have the ability to create several variables in the same environment but this time we are going to create an environment called develop that will have variables in this case called url
Alt Text

Now we have an environment called develop ready to be used.
but when you have to test your API deployed on the web, you should to create another environment called production.

By last

okay we have an environment but the question is how I use it ?

How I said in the beginning postman is a powerful tool that allow us to use its tools easily.

when we create an environment, it is automatic added to the following combo with all the created environments and to use it we just have to select our environment in this case called develop
Alt Text

Finally we just have to call the url variable that we create within the environment develop and to call the variable we must do it inside double brackets
example:
{{url}}/book
its equals to
http://localhost:3000/book
in post using url variable we will see something like the below

Alt Text

It's all on my part, I hope It's helpful.
Regards Joel.

Top comments (0)