Whiles using API clients you may run into issues where different URLs are for different projects you are working on. In order not to create confusion whiles building the next big app, setting up an environment on a per-project basis makes life easier. In this post, we will see how to set up an API environment in the Insomnia API client app.

Let us see how to set up an API environment in the Insomnia API client application.

Setting up the Insomnia API client

Firstly, open the Insomnia API client and a sidebar will be to the left. A “No environment” dropdown navigation is seen there. This is what you need to create a new environment with a specific URL for your project. An example is shown below.

Begin creating a new insomnia environment
Begin creating a new environment

Secondly, click on the dropdown menu that shows the option “Manage Environments”. Thirdly, click on it, it opens up a window with the “Sub Environments” showing with a plus-sign icon next to it.

Click on the plus sign to create a new environment
Click the plus sign to create a new environment

A small dropdown will show with the options, “Environment” and “Private Environment”. Next click on “Environment” and add your “base_url” and “path” variables and values into the JSON provided. After, double click on the “New Environment”, and type a name to save the environment. Finally, click on “Done” at the bottom right corner.

Add environment data to json and save
Add environment data and save

And that’s that, you can select your new environment from the sidebar. Enter the “base_url” and “path” and send the request. An example is below.

_.base_url_.path/whatever-route
Test the environment variables
Request sent using environment variables.

With this, we have set up an environment for the project in the Insomnia API client Application. This makes it easier to work with multiple projects in the Insomnia API client, speeding up your work.

You can read my other posts here.

Categorized in:

Programming,

Last Update: March 21, 2024

Tagged in:

, ,