Skip to content

Commit

Permalink
Add comment to get user method JC-726
Browse files Browse the repository at this point in the history
  • Loading branch information
TebyakinaEkaterina committed Aug 23, 2024
1 parent bc0c742 commit 1f17128
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/react/src/api/services/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export namespace UserService {
*/
export async function getCurrentUser(): Promise<User> {
const { data } = await http.get<UserDto>(userUrl);

// When the server fails to retrieve a user, it does not send an error,
// but an object with an avatar field equal to null.
// Therefore, we will throw an error when receiving such data.
if (JSON.stringify(data) === JSON.stringify(errorObject)) {
throw new Error('Failed to get current user');
}
Expand Down

0 comments on commit 1f17128

Please sign in to comment.