A fetch that returns Futures instead of Promises
MIT License
Use fetch as a Monadic Future
No just use fetch that returns a Future instead of a promise.
fetch()
with headers and text/json/xml responses🤔 What's Not there?
- Uses simple Arrays instead of Iterables
- No streaming, just Futurizes existing XMLHttpRequest response bodies
For more information about Futures see:
Usage
yarn install https://github.com/theodesp/fetch-future.git
add your future flavor
yarn add fluture // or data.task but no ramda-fantasy as it cannot abort!
import { fetchF } from 'fetch-future';
import Future from 'fluture';
const fetch = fetchF(Future);
fetch('https://jsonplaceholder.typicode.com/posts')
.chain(res => res.json()) // json() is also a Future!
.fork(console.error, console.log) // Future Fantasy!
import { fetchF } from 'fetch-future';
import Future from 'fluture';
const fetch = fetchF(Future);
const future = fetch('https://jsonplaceholder.typicode.com/posts')
.chain(res => res.json()) // json() is also a Future!
.fork(console.error, console.log) // Future to be resolved!
future.cancel(); // Aborts the fetch by calling cancel!
fetch('/posts', {
credentials: 'include'
});
fetchF :: Constructor -> CPS -> ( (input, options) -> Future )
MIT © theodesp