Postman set environment variable

Last modified 2 years ago
Danger icon
The last modifications of this post were around 2 years ago, some information may be outdated!

Summary

Postman has environment variables, convenient for things like JWT keys. This script takes response data and saves the JWT value.

Code

var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable('token', jsonData.data.JWT);