Vscode-restclient: Dynamic envs | set env var by HTTP response

Created on 30 Apr 2020  路  2Comments  路  Source: Huachao/vscode-restclient

In Postman, I can set a environment-variable by HTTP response ,JSON response by adding these codes to Tests.

const body = JSON.parse(responseBody);
if (body.code) {
       pm.environment.set("code", body.code)
}

Can I do like this in REST-CLIENT?

Most helpful comment

I was looking for the same ability,
requests variables seems to exists, but only with a file scope. Would be great to have "global requests variables" that overrides environment variables based on a response.

All 2 comments

@erfanium you could set it into a named variable

@code = {{requestName.response.body.$.code}}

I was looking for the same ability,
requests variables seems to exists, but only with a file scope. Would be great to have "global requests variables" that overrides environment variables based on a response.

Was this page helpful?
0 / 5 - 0 ratings