From da92fd705b8f03c46f72112b856781e28804aebc Mon Sep 17 00:00:00 2001 From: Scott Dutton Date: Mon, 19 Oct 2020 02:51:40 +0100 Subject: [PATCH] Replace headers in view (#1287) fixs #1257 Cant add this in the same place as the URL as you end in an infinate loop Co-authored-by: Liyas Thomas --- pages/index.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pages/index.vue b/pages/index.vue index a0afc74a8..0b0e2b37d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1790,6 +1790,17 @@ export default { return (this.response.headers["content-type"] || "").split(";")[0].toLowerCase() }, requestCode() { + let headers = [] + if (this.preRequestScript || hasPathParams(this.params)) { + let environmentVariables = getEnvironmentVariablesFromScript(this.preRequestScript) + environmentVariables = addPathParamsToVariables(this.params, environmentVariables) + for (let k of this.headers) { + const kParsed = parseTemplateString(k.key, environmentVariables) + const valParsed = parseTemplateString(k.value, environmentVariables) + headers.push({ key: kParsed, value: valParsed }) + } + } + return generateCodeWithGenerator(this.requestType, { auth: this.auth, method: this.method, @@ -1799,7 +1810,7 @@ export default { httpUser: this.httpUser, httpPassword: this.httpPassword, bearerToken: this.bearerToken, - headers: this.headers, + headers: headers, rawInput: this.rawInput, rawParams: this.rawParams, rawRequestBody: this.rawRequestBody,