Skip to content

Commit

Permalink
Going to try catch all api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jongan69 committed Jan 5, 2025
1 parent 918969a commit fad7a08
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/utils/getTrends.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export default async function getTrends() {
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/stats/getTrends`);
const trends = await data.json();
return trends;
try {
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/stats/getTrends`);
const trends = await data.json();
return trends;
} catch (error) {
console.error("Error fetching trends:", error);
return [];
}
}

0 comments on commit fad7a08

Please sign in to comment.