Skip to content
Discussion options

You must be logged in to vote

Hi @rmeshksar there's a roundabout way to accomplish what you're looking for. You can loop until all variables have been resolved/replaced by manually invoking the replaceIn method:

console.log(insomnia.variables.toObject());
let apiUrl = '{{apiUrl}}';
while (apiUrl.includes('{{')) {
	try {
    apiUrl = insomnia.variables.replaceIn(apiUrl);
	} catch (e) {
		console.error("could not resolve a variable in template", apiUrl);
		break;
	}
}
console.log(apiUrl);

this particular script is fault-tolerant and will log if a variable cannot be interpolated/resolved

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ryan-willis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants