From 965dfff7c6c1541530dd59676f140928c73abd96 Mon Sep 17 00:00:00 2001 From: Krishna Acondy Date: Mon, 18 Jan 2021 09:07:36 +0000 Subject: [PATCH] chore(*): use axios instead of fetch --- src/utils/parseAndSubmitAuthorizeForm.ts | 25 +++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/utils/parseAndSubmitAuthorizeForm.ts b/src/utils/parseAndSubmitAuthorizeForm.ts index 5a77090..7d3cb62 100644 --- a/src/utils/parseAndSubmitAuthorizeForm.ts +++ b/src/utils/parseAndSubmitAuthorizeForm.ts @@ -1,3 +1,5 @@ +import axios from 'axios' + export const parseAndSubmitAuthorizeForm = async ( response: string, serverUrl: string @@ -30,20 +32,11 @@ export const parseAndSubmitAuthorizeForm = async ( } } - return new Promise((resolve, reject) => { - if (authUrl) { - fetch(authUrl, { - method: 'POST', - credentials: 'include', - body: formData, - referrerPolicy: 'same-origin' - }) - .then((res) => res.text()) - .then((res) => { - resolve(res) - }) - } else { - reject('Auth form url is null') - } - }) + if (!authUrl) { + throw new Error('Auth Form URL is null or undefined.') + } + + return await axios + .post(authUrl, formData, { withCredentials: true, responseType: 'text' }) + .then((response) => response.data) }