Re: [whatwg/fetch] Why doesn't `fetch` reject if 400 ≤ status < 600? (#18)

// Typescript
export const fetcher = async <T = any>(
  input: RequestInfo,
  init?: RequestInit
): Promise<T> => {
  const response = await fetch(input, init);
  if (!response.ok) throw new Error(response.statusText);
  return response.json();
};

// Javscript
export const fetcher = async(input, init = {}) => {
  const response = await fetch(input, init);
  if (!response.ok) throw new Error(response.statusText);
  return response.json();
};

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/18#issuecomment-1200071905
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/18/1200071905@github.com>

Received on Saturday, 30 July 2022 02:43:38 UTC