Skip to content

Commit

Permalink
Merge pull request #713 from hngprojects/destinedcodes-patch-1
Browse files Browse the repository at this point in the history
Update page.tsx
  • Loading branch information
ThePrimeJnr authored Jul 29, 2024
2 parents b94eb06 + df4daa6 commit cfe9695
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_BACKEND_PROBE_URL=https://your-teams-backend-probe-url.com
API_URL=https://your-teams-backend-probe-url.com
17 changes: 7 additions & 10 deletions src/app/(landing-routes)/hng-test/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { unstable_noStore as noStore } from "next/cache";

export default async function HNGTEST() {
noStore();
const API_URL = process.env.API_URL || "No API URL provided";
let result = {} as { message?: string };
try {
if (process.env.NEXT_PUBLIC_BACKEND_PROBE_URL) {
const response = await fetch(
`${process.env.NEXT_PUBLIC_BACKEND_PROBE_URL}`,
{
cache: "no-store",
},
);
result = response.ok ? await response.json() : {};
}
const response = await fetch(API_URL);
result = response.ok ? await response.json() : {};
} catch {
result = {};
}
Expand All @@ -18,7 +15,7 @@ export default async function HNGTEST() {
<div className="space-y-2">
<h1 className="text-2xl font-semibold lg:text-3xl">HNG TEST BACKEND</h1>
<p>Version 0.12</p>
<p>{process.env.NEXT_PUBLIC_BACKEND_PROBE_URL || ""}</p>
<p>{API_URL}</p>
<p>{result?.message}</p>
</div>
</div>
Expand Down

0 comments on commit cfe9695

Please sign in to comment.