Skip to content

Commit

Permalink
refactor: reducing repetition in httpRequest's key
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun0157 committed Jun 10, 2024
1 parent 5431fa9 commit 2ecc883
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/replaceVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ export function replaceVariablesInRequest(request: RequestSpec, variables: Varia

type keyOfHttp = Exclude<keyof typeof request.httpRequest, "method">;
const httpPropertiesToReplace: string[] = ["baseUrl", "url", "params", "headers", "body"];
httpPropertiesToReplace.forEach((key) => {
const replacedData = replaceVariables(request.httpRequest[key as keyOfHttp], variables);
request.httpRequest[key as keyOfHttp] = replacedData.data;
httpPropertiesToReplace.forEach((prop) => {
const httpKey = prop as keyOfHttp;
const replacedData = replaceVariables(request.httpRequest[httpKey], variables);
request.httpRequest[httpKey] = replacedData.data;
undefs.push(...replacedData.undefinedVars);
});

Expand Down

0 comments on commit 2ecc883

Please sign in to comment.