Skip to content
Snippets Groups Projects
Commit e0ae0b2a authored by Trirst's avatar Trirst
Browse files

Only parse JSON if content length is not 0

parent a2bad358
No related branches found
No related tags found
No related merge requests found
async function fetchAPI(endpoint, options) { async function fetchAPI(endpoint, options) {
const res = await fetch(endpoint, options); const res = await fetch(endpoint, options);
const data = await res.json(); const contentType = res.headers.get('content-length');
let data
if (!contentType.includes("0")) {
data = await res.json();
}
if (res.ok) { if (res.ok) {
return data; return data;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment