Skip to content

Commit

Permalink
Handle get request errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mhasanince committed Nov 9, 2023
1 parent 6b45294 commit 8b60213
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/utils/api-client.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
const API_TOKEN = import.meta.env.API_TOKEN;

const get = async (url: string) => {
const response = await fetch(url, {
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${API_TOKEN}`,
'X-GitHub-Api-Version': '2022-11-28',
},
});
try {
const response = await fetch(url, {
headers: {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${API_TOKEN}`,
'X-GitHub-Api-Version': '2022-11-28',
},
});

return response.json();
return response.json();
} catch (error) {
console.error(error);
}
};

export const apiClient = {
Expand Down

0 comments on commit 8b60213

Please sign in to comment.