diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-29 11:53:41 +0000 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-29 11:53:41 +0000 |
| commit | ad2a780f5bb3e48d95ad2724eb4868bf43883c32 (patch) | |
| tree | b39ea0325e7fb3cfbef6d0d24a1225dda0595a7c /src/pages | |
| parent | 48bf60f8347db2a22f207441d463e649a9e4e08c (diff) | |
Types lib/api
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/[locale]/sign-up/index.astro | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/pages/[locale]/sign-up/index.astro b/src/pages/[locale]/sign-up/index.astro index 75103aa..5b99ec5 100644 --- a/src/pages/[locale]/sign-up/index.astro +++ b/src/pages/[locale]/sign-up/index.astro @@ -30,8 +30,6 @@ const t = translate(locale); </Page> <script> - import type { GetRegistrationOptionsResponseBody } from '$lib/api'; - import * as api from '$lib/api'; import { startRegistration } from '@simplewebauthn/browser'; import UserAlreadyExistsError from '$types/UserAlreadyExistsError'; @@ -154,7 +152,7 @@ const t = translate(locale); setIsFormDisabled(false); } - async function getRegistrationOptions(): Promise<GetRegistrationOptionsResponseBody> { + async function getRegistrationOptions() { const response = await api.getRegistrationOptions({ displayName: displayNameInput.value, userId: emailInput.value, @@ -171,12 +169,12 @@ const t = translate(locale); `); } - const body = await response.json(); + const body = { response }; if (!body) { return Promise.reject('Tried to get registration options on API, but got an empty reponse.'); } - return body as GetRegistrationOptionsResponseBody; + return body; } async function verifyRegistrationResponse( @@ -195,18 +193,17 @@ const t = translate(locale); `); } - const body = await response.json(); - if (body === true) { + if (response.body === true) { return true; } - if (body === false) { + if (response.body === false) { return false; } return Promise.reject(` Tried to verify registration response on API. Expected response to be - 'true' or 'false', but got: ${body} + 'true' or 'false', but got: ${response.body} `); } </script> |
