{"id":13570962,"url":"https://github.com/tryolabs/fetch-it","last_synced_at":"2025-06-27T10:07:01.049Z","repository":{"id":57234608,"uuid":"52633400","full_name":"tryolabs/fetch-it","owner":"tryolabs","description":"An enhanced HTTP client based on fetch.","archived":false,"fork":false,"pushed_at":"2016-05-02T23:42:20.000Z","size":78,"stargazers_count":237,"open_issues_count":1,"forks_count":13,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-06-11T07:13:22.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/tryolabs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-26T21:18:58.000Z","updated_at":"2023-04-21T16:42:12.000Z","dependencies_parsed_at":"2022-09-15T04:41:19.827Z","dependency_job_id":null,"html_url":"https://github.com/tryolabs/fetch-it","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tryolabs/fetch-it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryolabs%2Ffetch-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryolabs%2Ffetch-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryolabs%2Ffetch-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryolabs%2Ffetch-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tryolabs","download_url":"https://codeload.github.com/tryolabs/fetch-it/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryolabs%2Ffetch-it/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261244018,"owners_count":23129640,"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":[],"created_at":"2024-08-01T14:00:56.904Z","updated_at":"2025-06-27T10:07:01.027Z","avatar_url":"https://github.com/tryolabs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# fetch-it\nAn enhanced HTTP client based on fetch.\n\nBlogpost: [fetch-it an enhanced http client based on fetch] (http://blog.tryolabs.com/2016/03/02/fetch-it-enhanced-http-client-based-on-fetch/)\n\n## Features\nYou can do all the same thing that you do with fetch, plus:\n\n- Add middleware, to intercept requests and responses\n- Create custom config instances\n\n## Installation\n\nusing npm:\n```\n$ npm install --save fetch-it\n```\n\n## Examples\n\nGET request\n```js\nfetchIt.get('http://httpbin.org/get?param1=param1')\n  .then((response) =\u003e response.json())\n  .then((json) =\u003e console.log(json))\n  .catch((error) =\u003e console.error(error));\n```\n\nPOST request\n```js\nfetchIt.post('http://httpbin.org/post?param1=param1', {\n  param2: 'param2',\n  param3: 'param3'\n}).then((response) =\u003e response.json())\n  .then((json) =\u003e console.log(json))\n  .catch((error) =\u003e console.error(error));\n```\n\n## API\n\n### Request methods\n\n### `fetchIt.fetch(url[, options])`\n### `fetchIt.fetch(request)`\nYou can perform requests the same way as you do with fetch().\n\n```js\nfetchIt.fetch(url, {\n  method: 'POST',\n  body: JSON.stringify(data),\n  headers: {\n    'Content-Type': 'application/json'\n  }\n}).then((response) =\u003e {\n  // handle response\n}).catch((error) =\u003e {\n  // handle error\n});\n```\n\nAnd we provide some convenience aliases for the supported methods.\n\n### `fetchIt.get(url[, options])`\n### `fetchIt.get(request)`\n\n### `fetchIt.post(url[, data[, options]])`\n### `fetchIt.post(request)`\n\n### `fetchIt.put(url[, data[, options]])`\n### `fetchIt.put(request)`\n\n### `fetchIt.patch(url[, data[, options]])`\n### `fetchIt.patch(request)`\n\n### `fetchIt.delete(url[, options])`\n### `fetchIt.delete(request)`\n\n### `fetchIt.head(url[, options])`\n### `fetchIt.head(request)`\n\n\n### Creating custom config instances\nYou can create a custom config instance of fetchIt\n\n### `fetchIt.create([options])`\n\n```js\nlet apiFetch = fetchIt.create({\n  headers: {\n    'Authorization': 'Bearer ' + getAPIToken(),\n    'X-My-Custom-Header': 'CustomHeader'\n  }\n});\n\napiFetch.get(url).then((response) =\u003e {\n  // handle response\n}).catch((error) =\u003e {\n  // handle error\n});\n```\n\n### Middleware\nYou can add middleware objects to any instance, to intercept requests and responses.\n\nThe middleware object must have defined at least one of these methods:\n- `request(request)`, to intercept a request,\n- `requestError(error)`, to intercept an error from a previous middleware,\n- `response(response)`, to intercept a response,\n- `responseError(error)`, to intercept an error from a previous middleware.\n\n```js\nlet jsonMiddleware = {\n  response(res) {\n    return res.json().catch((e) =\u003e {\n      return e;\n    });\n  }\n};\n```\n\n### `fetchIt.addMiddlewares(ArrayOfMiddlewares)`\n\n```js\nfetchIt.addMiddlewares([jsonMiddleware]);\n```\n\n### `fetchIt.clearMiddlewares()`\n\n## Roadmap\n- Better docs\n- Add more middlewares\n- Add better tests\n- Add travis and coveralls\n- Create another project to create something similar to $resource based on fetch-it.\n\n## Credits\n`fetchIt` is heavily based on [Axios](https://github.com/mzabriskie/axios), but based on [`fetch()`](http://github.github.io/fetch).\n\n\n## License\nMIT © [Tryolabs](http://github.com/tryolabs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryolabs%2Ffetch-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryolabs%2Ffetch-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryolabs%2Ffetch-it/lists"}