1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

chore(*): use axios instead of fetch

This commit is contained in:
Krishna Acondy
2021-01-18 09:07:36 +00:00
parent ff64dd22ad
commit 965dfff7c6

View File

@@ -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)
}