From cd237c0315619a99948db4c0b313cd33d6a44e20 Mon Sep 17 00:00:00 2001 From: Binod Nepali Date: Mon, 29 Apr 2024 16:13:03 +0200 Subject: [PATCH] fix: remove hardcode base api url --- .env.sample | 1 + src/server/getProfile.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..e2c3f92 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +BASE_URL=http://localhost:8000/api \ No newline at end of file diff --git a/src/server/getProfile.ts b/src/server/getProfile.ts index 100609b..6707745 100644 --- a/src/server/getProfile.ts +++ b/src/server/getProfile.ts @@ -1,7 +1,10 @@ import { Profile } from "../types/Profile.ts"; +const env = Deno.env.toObject(); +const baseurl = env.BASE_URL || "http://localhost:8000/api"; + export const getProfile = async () => { - const response = await fetch("http://localhost:8000/api/profile"); + const response = await fetch(`${baseurl}/profile`); return await response.json() as Profile; };