Skip to content

Commit 323ad3f

Browse files
committed
chore: add error handling
1 parent 2f1159f commit 323ad3f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lib/helpers/dataFetchHelper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { API_URL } from "@/config";
22

33
export async function getData(url: string) {
44
try {
5+
if (!API_URL) {
6+
throw new Error("API_URL is not defined");
7+
}
8+
59
const response = await fetch(API_URL + url);
610
const data = await response.json();
711
return data;

0 commit comments

Comments
 (0)