diff --git a/frontend/static/js/api/profile.js b/frontend/static/js/api/profile.js index 1ec7987..dddc1ac 100644 --- a/frontend/static/js/api/profile.js +++ b/frontend/static/js/api/profile.js @@ -19,6 +19,10 @@ class Profile async init(user_id) { let response = await this.client._get(`/api/profiles/${user_id}`); + + if (response.status === 404) + return 1; + let response_data = await response.json(); this.user_id = response_data.user_id; diff --git a/frontend/static/js/api/profiles.js b/frontend/static/js/api/profiles.js index b12691f..a83c156 100644 --- a/frontend/static/js/api/profiles.js +++ b/frontend/static/js/api/profiles.js @@ -28,7 +28,8 @@ class Profiles async getProfile(user_id) { let profile = new Profile(this.client); - await profile.init(user_id); + if (await profile.init(user_id)) + return null; return profile; } diff --git a/frontend/static/js/views/ProfilePageView.js b/frontend/static/js/views/ProfilePageView.js index 90c3d4e..0ebe4ce 100644 --- a/frontend/static/js/views/ProfilePageView.js +++ b/frontend/static/js/views/ProfilePageView.js @@ -10,6 +10,10 @@ export default class extends AbstractView { async postInit() { let profile = await client.profiles.getProfile(this.user_id); + + if (profile === null) + return 1; + let info = document.getElementById("info"); // Username @@ -18,7 +22,7 @@ export default class extends AbstractView { username.appendChild(document.createTextNode(profile.username)); info.appendChild(username); - info.appendChild(document.createElement("br")); + info.appendChild(document.createElement("br")); // Avatar let avatar = document.createElement("img");