Skip to content

Commit

Permalink
fix: failed to fetch api call
Browse files Browse the repository at this point in the history
  • Loading branch information
binodnepali committed Apr 29, 2024
1 parent 6fdae79 commit 67c2c8a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/server/getProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import { Profile } from "../types/Profile.ts";
export const getProfile = async () => {
const baseurl = Deno.env.get("BASE_URL") || "http://localhost:8000/api";

console.log("baseurl", baseurl);
const url = `${baseurl}/profile`;

console.log(`Fetching data from ${url}`);

const response = await fetch(url);

if (!response.ok) {
throw new Error(`Failed to fetch data from ${url}`);
}

const response = await fetch(`${baseurl}/profile`);
return await response.json() as Profile;
};

Expand Down

0 comments on commit 67c2c8a

Please sign in to comment.