From 2df87b598303a90e73a2169367428140acac1ad7 Mon Sep 17 00:00:00 2001 From: danyal-deekoders Date: Tue, 14 May 2024 16:57:43 +0500 Subject: [PATCH] duplicate-image-issue New Uploaded image overrides old image. --- src/app/page.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 24cce7e..69078dd 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -75,7 +75,15 @@ export default function Home() { ); return; } - setUserImageUrl(response.profilePicUrl); + const image = await fetch(response.profilePicUrl); + const blob = await image.blob(); + const reader = new FileReader(); + + reader.onload = async (event: ProgressEvent) => { + setUserImageUrl(event.target?.result as string); + }; + + reader.readAsDataURL(blob); } catch (error) { console.error('Error fetching profile picture:', error); }