Just dumped Postman noobie question #6477
-
|
Hi all, and how/where can I create/store global vars Kind regards Pete Kane |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Currently, Bruno doesn't have any native API to check this. But as a workaround, you could do const resolveHost = async (primaryUrl, fallbackUrl) => {
try {
await bru.sendRequest({ url: primaryUrl, timeout: 2000 });
} catch(e) {
if (e.code === 'ECONNREFUSED') {
return fallbackUrl;
}
}
return primaryUrl;
}
const activeHost = await resolveHost('http://localhost:9653', 'https://echo.usebruno.com');
// bru.setVar('host', activeHost);
// bru.setEnvVar('host', activeHost);
bru.setGlobalEnvVar('host', activeHost); Read more about variables here: https://docs.usebruno.com/variables/overview |
Beta Was this translation helpful? Give feedback.
Currently, Bruno doesn't have any native API to check this. But as a workaround, you could do
Read more about variables here: https://docs.usebruno.com/variables/overview