diff options
author | André Oliveira <oliveira.andrerodrigues95@gmail.com> | 2023-09-28 16:11:37 +0100 |
---|---|---|
committer | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2023-09-30 10:13:48 +0100 |
commit | ec0914ae254af409da1f0b775460d5234b6484b7 (patch) | |
tree | a72acbd7cea38b0e68a31b311de6da1c9fed244e /src/api | |
parent | 6.5.0-nightly.19 [skip ci] (diff) | |
download | ferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.tar.gz ferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.tar.zst ferdium-app-ec0914ae254af409da1f0b775460d5234b6484b7.zip |
fix: login and signup error messages
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/server/ServerApi.ts | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 7b17fcdcd..8e1d45588 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts | |||
@@ -62,13 +62,19 @@ export default class ServerApi { | |||
62 | }, | 62 | }, |
63 | false, | 63 | false, |
64 | ); | 64 | ); |
65 | if (!request.ok) { | 65 | try { |
66 | throw new Error(request.statusText); | 66 | const responseJson = await request.json(); |
67 | } | ||
68 | const u = await request.json(); | ||
69 | 67 | ||
70 | debug('ServerApi::login resolves', u); | 68 | if (!request.ok) { |
71 | return u.token; | 69 | throw responseJson; |
70 | } | ||
71 | |||
72 | debug('ServerApi::login resolves', responseJson); | ||
73 | return responseJson.token; | ||
74 | } catch (error) { | ||
75 | debug('ServerApi::login ERROR:', error); | ||
76 | throw error; | ||
77 | } | ||
72 | } | 78 | } |
73 | 79 | ||
74 | async signup(data: any) { | 80 | async signup(data: any) { |
@@ -80,13 +86,19 @@ export default class ServerApi { | |||
80 | }, | 86 | }, |
81 | false, | 87 | false, |
82 | ); | 88 | ); |
83 | if (!request.ok) { | 89 | try { |
84 | throw new Error(request.statusText); | 90 | const responseJson = await request.json(); |
85 | } | ||
86 | const u = await request.json(); | ||
87 | 91 | ||
88 | debug('ServerApi::signup resolves', u); | 92 | if (!request.ok) { |
89 | return u.token; | 93 | throw responseJson; |
94 | } | ||
95 | |||
96 | debug('ServerApi::signup resolves', responseJson); | ||
97 | return responseJson.token; | ||
98 | } catch (error) { | ||
99 | debug('ServerApi::signup ERROR:', error); | ||
100 | throw error; | ||
101 | } | ||
90 | } | 102 | } |
91 | 103 | ||
92 | async inviteUser(data: any) { | 104 | async inviteUser(data: any) { |