{"id":16629023,"url":"https://github.com/bradgarropy/http","last_synced_at":"2025-07-14T00:36:01.303Z","repository":{"id":40056479,"uuid":"383658540","full_name":"bradgarropy/http","owner":"bradgarropy","description":"📻 http request library","archived":false,"fork":false,"pushed_at":"2022-05-19T02:38:08.000Z","size":88,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T16:04:43.375Z","etag":null,"topics":["ajax","eslint","fetch","http","jest","node","prettier","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@bradgarropy/http","language":"TypeScript","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/bradgarropy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-07T03:06:55.000Z","updated_at":"2025-03-02T13:52:13.000Z","dependencies_parsed_at":"2022-07-27T14:53:00.395Z","dependency_job_id":null,"html_url":"https://github.com/bradgarropy/http","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":"bradgarropy/node-library-starter","purl":"pkg:github/bradgarropy/http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradgarropy%2Fhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradgarropy%2Fhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradgarropy%2Fhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradgarropy%2Fhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bradgarropy","download_url":"https://codeload.github.com/bradgarropy/http/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bradgarropy%2Fhttp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265227935,"owners_count":23731063,"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":["ajax","eslint","fetch","http","jest","node","prettier","typescript"],"created_at":"2024-10-12T04:39:02.309Z","updated_at":"2025-07-14T00:36:01.238Z","avatar_url":"https://github.com/bradgarropy.png","language":"TypeScript","readme":"# 📻 http\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![github actions][github-actions-badge]][github-actions]\n[![coverage][codecov-badge]][codecov]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n[![contributors][contributors-badge]][contributors]\n[![discord][discord-badge]][discord]\n\n_📻 http request library heavily inspired by [axios][axios]._\n\nMost of the time, `fetch` is used to interact with a JSON API. This library is a thin wrapper around `fetch` that converts the request and response body to JSON by default.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@bradgarropy/http\"\u003e\n        \u003cimg alt=\"http\" src=\"./images/github.png\" width=\"500\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## 📦 Installation\n\nThis package is hosted on [npm][npm].\n\n```bash\nnpm install @bradgarropy/http\n```\n\n## 🥑 Usage\n\nThis library's API is very similar to [axios][axios]. You can issue HTTP requests which are assumed to be JSON by default. It returns a `Promise` with the response data.\n\n```javascript\nimport {http} from \"@bradgarropy/http\"\n\n// get all posts\nconst posts = await http.get(\"https://jsonplaceholder.typicode.com/posts\")\n\n// get one post\nconst post = await http.get(\"https://jsonplaceholder.typicode.com/posts/1\")\n\n// get posts by user\nconst userPosts = await http.get(\"https://jsonplaceholder.typicode.com/posts\", {\n    params: {\n        userId: 1,\n    },\n})\n\n// create a post\nconst newPost = await http.post(\"https://jsonplaceholder.typicode.com/posts\", {\n    body: {\n        userId: 1,\n        title: \"My post title\",\n        body: \"This is my post body.\",\n    },\n})\n\n// update a post\nconst newPost = await http.patch(\n    \"https://jsonplaceholder.typicode.com/posts/1\",\n    {\n        body: {\n            userId: 1,\n            title: \"My new post title\",\n            body: \"This is my new post body.\",\n        },\n    },\n)\n\n// delete a post\nconst oldPost = await http.delete(\n    \"https://jsonplaceholder.typicode.com/posts/1\",\n)\n```\n\n## 📖 API Reference\n\nEvery method assumes that the response coming back from the API is `json`.\n\nThe request `body` is converted to a `string` if the Content Type is `json`, or a `FormData` object if the Content Type is `form`. The request `body` is ignored when using the `GET` method.\n\n### `options`\n\nAll methods support an `options` object. Here are the set of supported options.\n\n| Name      | Required | Default | Example                              | Description                                                      |\n| --------- | -------- | ------- | ------------------------------------ | ---------------------------------------------------------------- |\n| `headers` | `false`  | `{}`    | `{\"authorization\": \"Bearer abc123\"}` | Headers object, similar to `fetch`.                              |\n| `params`  | `false`  | `{}`    | `{userId: 1}`                        | Query parameters object.                                         |\n| `body`    | `false`  | `{}`    | `{name: \"Brad Garropy\"}`             | Body to send to the API. Define the `Content-Type` using `type`. |\n| `type`    | `false`  | `json`  | `form`                               | Content type of the body. (`json` \\| `form`)                     |\n\n### `get(url, options)`\n\n| Name      | Required | Default | Example                                      | Description                  |\n| --------- | -------- | ------- | -------------------------------------------- | ---------------------------- |\n| `url`     | `true`   |         | `https://jsonplaceholder.typicode.com/posts` | Web address of the API.      |\n| `options` | `false`  | `{}`    | `{params: {userId: 1}}`                      | Request [options](#options). |\n\nPerform an HTTP GET request.\n\n```javascript\n// get without options\nhttp.get(\"https://jsonplaceholder.typicode.com/posts\")\n\n// get with  options\nhttp.get(\"https://jsonplaceholder.typicode.com/posts\", {\n    headers: {authorization: \"Bearer abc123\"},\n    params: {userId: 1},\n    body: {\n        first: \"Brad\",\n        last: \"Garropy\",\n    },\n    type: \"json\",\n})\n```\n\n### `post(url, options)`\n\n| Name      | Required | Default | Example                                      | Description                  |\n| --------- | -------- | ------- | -------------------------------------------- | ---------------------------- |\n| `url`     | `true`   |         | `https://jsonplaceholder.typicode.com/posts` | Web address of the API.      |\n| `options` | `false`  | `{}`    | `{params: {userId: 1}}`                      | Request [options](#options). |\n\nPerform an HTTP POST request.\n\n```javascript\n// post without options\nhttp.post(\"https://jsonplaceholder.typicode.com/posts\")\n\n// post with options\nhttp.post(\"https://jsonplaceholder.typicode.com/posts\", {\n    headers: {authorization: \"Bearer abc123\"},\n    params: {userId: 1},\n    body: {\n        first: \"Brad\",\n        last: \"Garropy\",\n    },\n    type: \"json\",\n})\n```\n\n### `patch(url, options)`\n\n| Name      | Required | Default | Example                                      | Description                  |\n| --------- | -------- | ------- | -------------------------------------------- | ---------------------------- |\n| `url`     | `true`   |         | `https://jsonplaceholder.typicode.com/posts` | Web address of the API.      |\n| `options` | `false`  | `{}`    | `{params: {userId: 1}}`                      | Request [options](#options). |\n\nPerform an HTTP PATCH request.\n\n```javascript\n// patch without options\nhttp.patch(\"https://jsonplaceholder.typicode.com/posts\")\n\n// patch with options\nhttp.patch(\"https://jsonplaceholder.typicode.com/posts\", {\n    headers: {authorization: \"Bearer abc123\"},\n    params: {userId: 1},\n    body: {\n        first: \"Brad\",\n        last: \"Garropy\",\n    },\n    type: \"json\",\n})\n```\n\n### `delete(url, options)`\n\n| Name      | Required | Default | Example                                      | Description                  |\n| --------- | -------- | ------- | -------------------------------------------- | ---------------------------- |\n| `url`     | `true`   |         | `https://jsonplaceholder.typicode.com/posts` | Web address of the API.      |\n| `options` | `false`  | `{}`    | `{params: {userId: 1}}`                      | Request [options](#options). |\n\nPerform an HTTP DELETE request.\n\n```javascript\n// delete without options\nhttp.delete(\"https://jsonplaceholder.typicode.com/posts\")\n\n// delete with options\nhttp.delete(\"https://jsonplaceholder.typicode.com/posts\", {\n    headers: {authorization: \"Bearer abc123\"},\n    params: {userId: 1},\n    body: {\n        first: \"Brad\",\n        last: \"Garropy\",\n    },\n    type: \"json\",\n})\n```\n\n## ❔ Questions\n\n🐛 report bugs by filing [issues][issues]  \n📢 provide feedback with [issues][issues] or on [twitter][twitter]  \n🙋🏼‍♂️ use my [ama][ama] or [twitter][twitter] to ask any other questions\n\n## ✨ contributors\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://bradgarropy.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/11336745?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBrad Garropy\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/bradgarropy/http/commits?author=bradgarropy\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/bradgarropy/http/commits?author=bradgarropy\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/bradgarropy/http/commits?author=bradgarropy\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#infra-bradgarropy\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n[codecov]: https://app.codecov.io/gh/bradgarropy/http\n[contributing]: https://github.com/bradgarropy/http/blob/master/contributing.md\n[contributors]: #-contributors\n[npm]: https://www.npmjs.com/package/@bradgarropy/http\n[codecov-badge]: https://img.shields.io/codecov/c/github/bradgarropy/http?style=flat-square\n[version-badge]: https://img.shields.io/npm/v/@bradgarropy/http.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@bradgarropy/http?style=flat-square\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[contributors-badge]: https://img.shields.io/github/all-contributors/bradgarropy/http?style=flat-square\n[issues]: https://github.com/bradgarropy/http/issues\n[twitter]: https://twitter.com/bradgarropy\n[ama]: https://bradgarropy.com/ama\n[bundlephobia]: https://bundlephobia.com/result?p=@bradgarropy/http\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@bradgarropy/http?style=flat-square\n[github-actions]: https://github.com/bradgarropy/http/actions\n[github-actions-badge]: https://img.shields.io/github/workflow/status/bradgarropy/http/%F0%9F%9A%80%20release?style=flat-square\n[typescript]: https://www.typescriptlang.org/dt/search?search=%40bradgarropy%2Fhttp\n[typescript-badge]: https://img.shields.io/npm/types/@bradgarropy/http?style=flat-square\n[discord]: https://bradgarropy.com/discord\n[discord-badge]: https://img.shields.io/discord/748196643140010015?style=flat-square\n[axios]: https://github.com/axios/axios\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradgarropy%2Fhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbradgarropy%2Fhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbradgarropy%2Fhttp/lists"}