Skip to content

Commit

Permalink
fix type bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ncukondo committed Dec 18, 2023
1 parent eb1654f commit b1fd49a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ const apiPost = async <PostData extends object, Response extends object>(
};

const apiGet = async <Response extends object>(api: string): Promise<Response> => {
try {
const res = await fetch(api, {
method: "GET",
});
if (res.ok) {
const data = (await res.json()) as Response;
return data;
}
} catch (e) {
console.log(e);
const res = await fetch(api, {
method: "GET",
});
if (res.ok) {
const data = (await res.json()) as Response;
return data;
}
throw new Error(`Cannot get fromapi:${api},${JSON.stringify(res, null, 2)}`);
};
Expand Down

0 comments on commit b1fd49a

Please sign in to comment.