-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1819 from NK-Works/profilepage
Proper Profile Page (Dynamic)
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,7 +167,7 @@ <h2>Change Password</h2> | |
|
||
}); | ||
</script> | ||
|
||
<script src="profile.js"></script> | ||
main | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// profile.js | ||
document.addEventListener("DOMContentLoaded", async () => { | ||
try { | ||
// Fetch user profile data from backend | ||
const response = await fetch("http://localhost:5000/api/users/profile", { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": `Bearer ${localStorage.getItem("authToken")}`, // Use your auth token here | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to fetch profile data."); | ||
} | ||
|
||
// Parse the JSON data | ||
const profileData = await response.json(); | ||
|
||
// Populate profile data in HTML | ||
document.querySelector(".profile-name").textContent = profileData.username; | ||
document.querySelector(".profile-email").textContent = `Email: ${profileData.email}`; | ||
} catch (error) { | ||
console.error("Error fetching profile data:", error); | ||
} | ||
}); |
17d0226
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
word-wise – ./
word-wise-anshikas-projects-45924011.vercel.app
word-wise-pi.vercel.app
word-wise-git-main-anshikas-projects-45924011.vercel.app