Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
incredible-phoenix246 committed Jul 29, 2024
1 parent 4b44f90 commit 4bc4694
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
API_URL=https://your-teams-backend-probe-url.com
NEXT_PUBLIC_API_URL=
AUTH_SECRET=
9 changes: 7 additions & 2 deletions src/app/(landing-routes)/hng-test/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ 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";
const API_URL =
process.env.API_URL ||
`${process.env.NEXT_PUBLIC_API_URL}/probe` ||
"No API URL provided";
let result = {} as { message?: string };
let text = "";
try {
const response = await fetch(API_URL);
text = await response.text();
result = response.ok ? await response.json() : {};
} catch {
result = {};
Expand All @@ -16,7 +21,7 @@ export default async function HNGTEST() {
<h1 className="text-2xl font-semibold lg:text-3xl">HNG TEST BACKEND</h1>
<p>Version 0.12</p>
<p>{API_URL}</p>
<p>{result?.message}</p>
<p>{result?.message || text}</p>
</div>
</div>
);
Expand Down

0 comments on commit 4bc4694

Please sign in to comment.