typicode/fetchival

Shouldn't assume all requests will return JSON. Alternatively, document that this is the expectation.

Closed this issue · 1 comments

fetchival's API is nice (because with ES7, fetching an HTML snippet looks like the following with plain ol' fetch - it's pretty awkward)

(async function main() {
    let content = fetch('/index.html');
    console.log(await (await content).text());
})()

Trying to pull this file through fetchival ends up bugging out as JSON.parse() obviously has no clue how to handle XML/HTML, and a quick glance through the source made it clear that this was what was being done, but throwing this in the README might be useful, or adding an option to parse the return as plain text.

I might tackle this myself and PR, but the issue is good to have documented either way.

Cool feature, thanks for the PR 👍