Replies: 1 comment
-
The solution was to change SetEnvVar to SerVar. Also, axios should be called async. Here's a modified script that works: `const axios = require('axios'); const calculateTokenExpiry = (tokenExpiryVarName) => { const authenticateClient = async (config) => { //console.log('Checking for required variables...') const oneMinute = 60000 if (expiryDifference >= oneMinute && bru.getVar('lastRequestEnvName') === bru.getEnvName()){
try {
} catch (error) { } await authenticateClient({ ` |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I’m working on a script to handle authentication tokens, but I’ve run into an issue where the variables I set are only available per request, not across the entire collection. I need these variables, like the token and its expiry, to persist throughout multiple requests within the collection.
Here’s the script I’m using to fetch and reuse the authentication token:
The problem is, even though I store the token and expiry date in environment variables, they don’t seem to persist across other requests in the same collection. Is there a way to make these variables available across all requests in a collection during runtime?
Any guidance or suggestions would be really appreciated!
Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions