Skip to content

Commit

Permalink
fix code gen for lead api service with query params
Browse files Browse the repository at this point in the history
  • Loading branch information
minizwergi committed Nov 16, 2023
1 parent 945a9ae commit af93d30
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/templates/exportService.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ export const {{{lowerCase name}}}{{{@root.postfix}}}Factory = ({ baseUrl, httpCl
let url = `${baseUrl}{{{escapePath path}}}`;
{{#if parametersQuery}}

const params = new URLSearchParams();
const urlWithParams = new URL(url);

{{#each parametersQuery}}
if ({{{name}}}) {
params.append('{{{name}}}', `${ {{{name}}} }`);
urlWithParams.searchparams.append('{{{name}}}', `${ {{{name}}} }`);
}
{{/each}}
if (params.values.length > 0) {
url += `?${params.toString()}`;
}
url = urlWithParams.href
{{/if}}
{{#if (isEqual method 'GET')}}
return httpClient.{{{lowerCase method}}}(url, {{>accessTokenOrUndefined}} timeout);
Expand Down

0 comments on commit af93d30

Please sign in to comment.