Skip to content

Commit

Permalink
Catch 404 from get UserProfile call
Browse files Browse the repository at this point in the history
  • Loading branch information
pcatkins committed Jan 18, 2024
1 parent bc14e6d commit eedad75
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import axios from "axios";

import { getClient } from "@/api/client";
import type { Components } from "@/types/openapi";

Expand All @@ -9,8 +11,13 @@ const getUserInfo = async (): Promise<Components.Schemas.UserProfile | null> =>
// Check if the response has data and userInfo property
return response?.data?.userInfo ?? null;
} catch (error) {
// Handle the error
console.log("Error fetching user info:", error);
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
console.log("User not found:", error);
} else {
console.log("Error fetching user info:", error);
}
}
return null;
}
};
Expand Down

0 comments on commit eedad75

Please sign in to comment.