{"id":15490441,"url":"https://github.com/theodesp/fetch-future","last_synced_at":"2025-04-22T19:08:14.805Z","repository":{"id":97066510,"uuid":"86060722","full_name":"theodesp/fetch-future","owner":"theodesp","description":"A fetch that returns Futures instead of Promises","archived":false,"fork":false,"pushed_at":"2024-01-02T15:51:37.000Z","size":173,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T19:08:05.443Z","etag":null,"topics":["assert","fetch","futures","mocha","monad"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-24T11:25:06.000Z","updated_at":"2024-01-02T15:51:41.000Z","dependencies_parsed_at":"2025-03-04T04:31:02.244Z","dependency_job_id":"fce1ad6f-2e61-4a01-8b18-ff1b5c8fb041","html_url":"https://github.com/theodesp/fetch-future","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Ffetch-future","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Ffetch-future/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Ffetch-future/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Ffetch-future/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/fetch-future/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250306638,"owners_count":21408926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","fetch","futures","mocha","monad"],"created_at":"2024-10-02T07:21:21.136Z","updated_at":"2025-04-22T19:08:14.784Z","avatar_url":"https://github.com/theodesp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [![Fetch-Future](logo.png)](#fetch-future)\n\n\u003e Use fetch as a Monadic Future\n\n# What? Fetch the future?\nNo just use fetch that returns a Future instead of a promise.\n\n\n-   **Minimal:** just `fetch()` with headers and text/json/xml responses\n-   **Modern:** written in ES2015\n-   **Cancellable** you can cancel the fetch once dispatched\n-   **Add your own Future** you can add your own Future Library as long as it implements the \n-   **Monadic** \n\n\u003e 🤔 **What's Not there?**\n\u003e\n\u003e -   Uses simple Arrays instead of Iterables\n\u003e -   No streaming, just Futurizes existing XMLHttpRequest response bodies\n\n\nFor more information about Futures see:\n* [Comparison of Futures to Promises](https://github.com/fluture-js/Fluture/wiki/Comparison-to-Promises)\n\nUsage\n\u003e yarn install https://github.com/theodesp/fetch-future.git\n\nadd your future flavor\n\n\u003e yarn add fluture // or data.task but no ramda-fantasy as it cannot abort!\n\n\nExample\n-------\n\n### Fetch some objects from an api\n\n```js\nimport { fetchF } from 'fetch-future';\nimport Future from 'fluture';\n\nconst fetch = fetchF(Future);\n\nfetch('https://jsonplaceholder.typicode.com/posts')\n  .chain(res =\u003e res.json()) // json() is also a Future!\n  .fork(console.error, console.log) // Future Fantasy!\n```\n\n### Cancel a future!\n# [![](cancel.jpg)](#cancel)\n\n```js\nimport { fetchF } from 'fetch-future';\nimport Future from 'fluture';\n\nconst fetch = fetchF(Future);\n\nconst future = fetch('https://jsonplaceholder.typicode.com/posts')\n  .chain(res =\u003e res.json()) // json() is also a Future!\n  .fork(console.error, console.log) // Future  to be resolved!\n  \nfuture.cancel(); // Aborts the fetch by calling cancel!\n```\n\n## Fetch Caveats\n* By default, fetch **won't send or receive any cookies** from the server, resulting in unauthenticated \nrequests if the site relies on maintaining a user session.\n\n```js\nfetch('/posts', {\n  credentials: 'include'\n});\n```\n\n* The Promise returned from fetch() won't reject on HTTP error status \neven if the response is an HTTP 404 or 500. \nInstead, it will resolve normally, and it will only reject \non network failure or if anything prevented the request from completing.\n\n## API\n\n```hs\nfetchF :: Constructor -\u003e CPS -\u003e ( (input, options) -\u003e Future )\n```\n\n## License\n\nMIT © [theodesp](https://theodesp.github.io)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Ffetch-future","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Ffetch-future","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Ffetch-future/lists"}