Skip to content

Commit

Permalink
fix erros and change to axios
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnau Zapata Delgado authored and Arnau Zapata Delgado committed Jul 13, 2023
1 parent 0c11fa5 commit 47aeaae
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/services/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class ApiClient {
static API_NAMES = {
UUID: `/uuid`,
VERIFY: `/certifications/verify`,
VERIFY_V2: `v2/certifications/verify`
VERIFY_V2: `/v2/certifications/verify`
}
static API_ERRORS = {
ERR_BAD_REQUEST: 'ERR_BAD_REQUEST',
Expand All @@ -14,26 +14,23 @@ export default class ApiClient {
static async verifyFile(file: File) {
const formData = new FormData()
formData.append('file', file, file.name)
var requestOptions = {
method: 'PUT',
body: formData
// redirect: 'follow'
}
let response: Response

let response

try {
response = await fetch(
response = await axios.put(
`${ApiClient.API_NODE}${ApiClient.API_NAMES.VERIFY}`,
requestOptions
formData
)
if (!response.ok) throw ''
} catch (error) {
response = await fetch(
response = await axios.put(
`${ApiClient.API_NODE}${ApiClient.API_NAMES.VERIFY_V2}`,
requestOptions
formData
)
} finally {
const responseData = await response.text()
return JSON.parse(responseData)
const responseData = await response.data
return responseData
}
}
static async getIPSFFromUuid(uuid) {
Expand Down

0 comments on commit 47aeaae

Please sign in to comment.