Just a higher-order function around fetch.
const createFetch = <T>(fn: (response: Response) => Promise<T>) => {
return (...params: Parameters<typeof fetch>) => fetch(...params).then(fn);
};
You can use it like this:
const fetchJSON = createFetch(response => response.json());
fetchJSON('https://pokeapi.co/api/v2/pokemon/squirtle').then(console.log);
// logs whatever data came back from the pokeapi