Skip to content

Commit

Permalink
Fixed api utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DevNico committed Apr 8, 2021
1 parent dd3a781 commit 1c15c2c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand All @@ -59,11 +62,12 @@ export const validateCorsignToken = async (
): Promise<CorsignToken> => {
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();
}
};

0 comments on commit 1c15c2c

Please sign in to comment.