Task for Fetch API
Transforms Fetch into a lazy composable single path1 utility.
npm install yet-another-fetch
import {runTask, taskStr} from 'yet-another-fetch'
// some standard Fetch options
const fetchOpts = {
method: 'GET'
headers: new Headers(..),
mode: 'cors'
}
const url = 'https://gist.github.com/../..'
// runTask retuns a list of `kill` and `futureValue`
// calling kill.kill() will prevent the fetch from happening
// futureValue contains the result of the fetch either an error or a value
const [kill, futureValue] = runTask(taskStr(url, fetchOpts))
// futureValue contains a map method to allow a way access the data inside
futureValue.map(console.log) // => either the fetch data string or an error
A task for fetching string based content
A task for fetching JSON based content
A task for fetching blobs (images/etc)
A task for handling ArrayBuffers (sound/etc)
A task for handling form objects
The method that actually runs the task (nothing is fetched until this method is called), imported from yet
1Task used in this library is yet which provides a single path or only cares about resolving values. The errors handled in this library are done via Either monad from data.either