blob: a6e22efda5b1d88e75a00c730615661375f0459e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
export default async (url) => {
const response = await fetch(url);
if (!response.ok) return null;
// is it json?
const contentType = response.headers.get("content-type");
if (contentType && contentType.includes("application/json")) {
return await response.json();
}
// fallback to text
return await response.text();
};
|