diff --git a/src/client.ts b/src/client.ts index f9951e2..33a275e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -12,10 +12,20 @@ export const signUp = async (payload: SignUpPayload): Promise => { method: 'POST', body: JSON.stringify(payload), headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json; charset=UTF-8' } }); + if (!res.ok) { + const isJson = res.headers + .get('Content-Type') + ?.includes('application/json'); + + const data = isJson ? await res.json() : await res.text(); + + throw new Error(data); + } + const user = await res.json(); return user;