question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Save value(s) from response to environment

See original GitHub issue

I have several login requests defined. The response of every request contains a token. I would like to save the token to an environment settings for later use by other requests using the token in their authentication header as a bearer token.

It can be done for instance by defining a function that would be executed after a request is done. Its response would be passed to this function containing a simple code:

function (response) {
  Environment["localhost"].token = response.token;
}

It would allow to run whatever defined login requests (e.g. with various users) and then test other requests.

I know there is a functionality to create a tag as a value of a property in the environment that would take the value from a specified request, but the point here is the request is not known when the tag is created. By using a tag you can’t have more login requests, send one of them and expect that the token value will be used later by other requests since you have to run just the one specified in the tag.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:5

github_iconTop GitHub Comments

2reactions
baskancommented, Sep 27, 2019

it’s a huge missing feature. sad to see this being closed

0reactions
Kirjycommented, Mar 31, 2020

@baskan is chaining request not what you’re looking for or am I missing something? https://support.insomnia.rest/article/43-chaining-requests

Chaining request seems to do part of the job but not entierly. If you have 2 different possible resources to authenticate, I didn’t figure out how to put the last result of the last executed request into the variable. It seems you just can put the result of only one request per variable. Am I mistaken ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature Request] Save value(s) from response to ...
I have several login requests defined. The response of every request contains a token. I would like to save the token to an...
Read more >
Extracting Data from Responses and Chaining Requests
This opens up a number of new possibilities. One of them is extracting values from the response and saving it inside an environment...
Read more >
How to update environment variables based on a ... - YouTube
Sometimes, the response from a request is required first in order to continue with all the other API requests currently stored in your ......
Read more >
Chaining Requests
Insomnia allows chaining requests, or the ability to extract values from the responses of other requests. Values are passed using Template Tags and...
Read more >
api - How to get values of variables from one Postman ...
https://github.com/postmanlabs/postman-app-support/issues/4968. The feature is not supported yet but a feature request is already opened.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found