Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions templates/base/http-clients/fetch-http-client.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.JsonApi]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
[ContentType.FormData]: (input: any) => {
if (input instanceof FormData) {
return input;
}

return Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
Expand All @@ -118,7 +122,8 @@ export class HttpClient<SecurityDataType = unknown> {
`${property}`
);
return formData;
}, new FormData()),
}, new FormData());
},
[ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
}

Expand Down
Loading