From 28700319be125e90ac478b417ed175ae2eb7b261 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 8 Aug 2024 00:07:09 +0200 Subject: [PATCH] refactor code --- .../community/user/[userId]/+page.svelte | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/routes/community/user/[userId]/+page.svelte b/src/routes/community/user/[userId]/+page.svelte index 7a02a695..97cdc7db 100644 --- a/src/routes/community/user/[userId]/+page.svelte +++ b/src/routes/community/user/[userId]/+page.svelte @@ -6,26 +6,14 @@ import { onMount} from 'svelte'; import {getImageURL } from '$lib/utils'; - import {userRegion, setCache, getCache, numberOfUnreadNotification } from '$lib/store'; + import {setCache, getCache, numberOfUnreadNotification } from '$lib/store'; import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; - import communityBanner from '$lib/images/community_banner.jpg'; export let data; export let form; - const usRegion = ['cle1','iad1','pdx1','sfo1']; - - let fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL; - - userRegion.subscribe(value => { - if (usRegion.includes(value)) { - fastifyURL = import.meta.env.VITE_USEAST_FASTIFY_URL; - } else { - fastifyURL = import.meta.env.VITE_EU_FASTIFY_URL; - } - }); let userData = { "karma": 0, @@ -56,7 +44,7 @@ const getUserData = async() => { const postData = {'userId': data?.userId}; - const response = await fetch(fastifyURL+'/get-user-data', { + const response = await fetch(data?.fastifyURL+'/get-user-data', { method: 'POST', headers: { "Content-Type": "application/json" @@ -108,7 +96,7 @@ const getUserStats = async () => { const postData = {'userId': data?.userId}; // make the POST request to the endpoint - const response = await fetch(fastifyURL + '/get-user-stats', { + const response = await fetch(data?.fastifyURL + '/get-user-stats', { method: 'POST', headers: { "Content-Type": "application/json" @@ -136,7 +124,7 @@ const getModerators = async () => { } else { // make the POST request to the endpoint - const response = await fetch(fastifyURL + '/get-moderators', { + const response = await fetch(data?.fastifyURL + '/get-moderators', { method: 'GET', headers: { "Content-Type": "application/json" @@ -170,7 +158,7 @@ async function getPost() { }; // Make the POST request to the endpoint - const response = await fetch(fastifyURL+'/get-post', { + const response = await fetch(data?.fastifyURL+'/get-post', { method: 'POST', headers: { "Content-Type": "application/json" @@ -225,7 +213,6 @@ onMount(async () => { - @@ -233,7 +220,6 @@ onMount(async () => { -