Skip to content

Commit

Permalink
fix: add fix for email request content-type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ayan-bloomscorp committed Apr 13, 2024
1 parent e65efa1 commit b7c8a3f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/transmission/transmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function executeGetPayload<T extends ITransmissionResponse, S>(

export function executePostPayload<T>(
url: string,
payload: T,
payload: T | FormData,
headers: Headers | undefined,
onPreExecute: () => void,
onPostExecute: (response: ITransmissionResponse) => void,
Expand All @@ -80,11 +80,22 @@ export function executePostPayload<T>(

onPreExecute();

fetch(url, {
const requestOptions: RequestInit = {
method: 'POST',
headers,
body: JSON.stringify(payload)
})
headers: headers,
};

if (payload instanceof FormData) {
requestOptions.body = payload;
} else {
requestOptions.body = JSON.stringify(payload);
requestOptions.headers = {
...requestOptions.headers,
'Content-Type': 'application/json',
};
}

fetch(url, requestOptions)
.then((response: Response) => response.json() as PromiseLike<ITransmissionResponse>)
.then(
(response: ITransmissionResponse): void => {
Expand Down

0 comments on commit b7c8a3f

Please sign in to comment.