Skip to content

Commit

Permalink
fix : check body text (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper200207 authored Jul 6, 2024
1 parent 843c7dc commit d65f570
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/app/api/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ export const fetcher = (options?: FetcherOptions) => {
response = await interceptors.response(response);
}

const method = config?.method ?? 'GET';
let body = {};
const bodyText = await response.text();
const body = bodyText ? JSON.parse(bodyText) : null;

if (response.ok && method === 'GET') {
body = await response.json();
}
return { ok: true, body };
} catch (error) {
let message = '';
Expand Down

0 comments on commit d65f570

Please sign in to comment.