From 1c15c2c69c476c884c3f668286c03c71e6595529 Mon Sep 17 00:00:00 2001 From: Nicolas Schlecker Date: Thu, 8 Apr 2021 11:18:19 +0200 Subject: [PATCH] Fixed api utils --- src/api.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/api.ts b/src/api.ts index 18fd272..6aafce9 100644 --- a/src/api.ts +++ b/src/api.ts @@ -38,12 +38,15 @@ export const generateSignedCorsignToken = async ( body: JSON.stringify(payload), }); - const { data, errors } = await response.json(); - if (response.ok) { - return data as GenerateSignedCorsignTokenResponse; + const jsonString = await response.text(); + const data = JSON.parse( + jsonString + ) as GenerateSignedCorsignTokenResponse; + + return data; } else { - return Promise.reject(errors); + return Promise.reject(); } }; @@ -59,11 +62,12 @@ export const validateCorsignToken = async ( ): Promise => { const response = await fetch(`${apiUrl}/validate/${token}`); - const { data, errors } = await response.json(); - if (response.ok) { - return data as CorsignToken; + const jsonString = await response.text(); + const data = JSON.parse(jsonString) as CorsignToken; + + return data; } else { - return Promise.reject(errors); + return Promise.reject(); } };