{"id":23915600,"url":"https://github.com/tien/regrest","last_synced_at":"2025-04-11T17:26:30.305Z","repository":{"id":50252985,"uuid":"145108762","full_name":"tien/regrest","owner":"tien","description":"micro http client - modern promise based","archived":false,"fork":false,"pushed_at":"2021-06-04T00:21:48.000Z","size":1284,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T23:29:54.958Z","etag":null,"topics":["ajax","http-client","javascript","nodejs","promise"],"latest_commit_sha":null,"homepage":"","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/tien.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-17T10:45:59.000Z","updated_at":"2023-11-07T12:49:28.000Z","dependencies_parsed_at":"2022-09-05T15:11:34.896Z","dependency_job_id":null,"html_url":"https://github.com/tien/regrest","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tien%2Fregrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tien%2Fregrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tien%2Fregrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tien%2Fregrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tien","download_url":"https://codeload.github.com/tien/regrest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248311668,"owners_count":21082630,"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","http-client","javascript","nodejs","promise"],"created_at":"2025-01-05T11:37:33.514Z","updated_at":"2025-04-11T17:26:30.268Z","avatar_url":"https://github.com/tien.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Regrest - Micro HTTP client\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![npm version](https://badge.fury.io/js/regrest.svg)](https://badge.fury.io/js/regrest)\n[![](https://img.shields.io/badge/gzip%20size-8%20kB-44cc11.svg)](https://cdn.jsdelivr.net/npm/regrest/lib/index.umd.min.js)\n[![install size](https://packagephobia.now.sh/badge?p=regrest)](https://packagephobia.now.sh/result?p=regrest)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\nMicro Promise based HTTP client for the browser and node.js\n\n## ✨ Features\n\n- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser\n- Make [http](http://nodejs.org/api/http.html) requests from node.js\n- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API\n- Built in [TypeScript](https://www.typescriptlang.org/) support\n\n## 👍🏻 Browser Support\n\n| ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |\n| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |\n| Latest ✔                                                                                 | Latest ✔                                                                                    | Latest ✔                                                                                 | Latest ✔                                                                              | Latest ✔                                                                           | 11 ✔                                                                                                                         |\n\n### NOTE\n\nIf you intend to support Internet Explorer, be sure to have a [poly-fill](https://github.com/taylorhakes/promise-polyfill) that adds a global `Promise` object\n\n## 🏗 Installing\n\nUsing npm:\n\n```bash\n$ npm install regrest\n```\n\nUsing cdn:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/regrest/lib/index.umd.min.js\"\u003e\u003c/script\u003e\n```\n\n## 🎬 Example\n\nRegrest is designed to be the simplest way possible to make http calls\n\nPerforming a `GET` request\n\n```js\n// Import using NodeJS or CommonJS module\nconst regrest = require(\"regrest\").default;\n// Or using ES6 module\nimport regrest from \"regrest\";\n\n// Use Promise\nregrest\n  .get(\"/man/bear/pig\")\n  // Print the raw response string\n  .then((response) =\u003e console.log(response.text))\n  // Print any error if occurred\n  .catch((error) =\u003e console.log(`*** Error: ${error}`));\n\n// Or use the new async/await keywords\nconst getGood = async () =\u003e {\n  try {\n    // Store the response in a variable\n    const response = await regrest.get(\"/foo/bar.json\");\n    // print out the parsed response\n    console.log(response.json);\n  } catch (error) {\n    // Print any error if occurred\n    console.log(`*** Error: ${error}`);\n  }\n};\n\ngetGood();\n\n// Or use callbacks\n// WE DON'T DO THAT HERE\n```\n\nPerforming a `POST` request\n\n```js\nregrest\n  .post(\"/comment\", JSON.stringify({ name: \"Foo\", comment: \"Bar\" }))\n  .then((response) =\u003e console.log(response.status, response.statusText))\n  .catch((error) =\u003e console.log(error));\n```\n\n## 📚 Documentation\n\n### Convenience methods\n\n##### regrest.request(options)\n\n##### regrest.get(url[, options])\n\n##### regrest.head(url[, options])\n\n##### regrest.post(url[, data[, options]])\n\n##### regrest.put(url[, data[, options]])\n\n##### regrest.delete(url[, options])\n\n##### regrest.options(url[, options])\n\n##### regrest.patch(url[, data[, options]])\n\n### Options options\n\n```js\n// Default options are marked with *\nconst options = {\n  method: \"GET\", // *GET, POST, PUT, DELETE, etc.\n  url: \"https://some-domain.com/api/\",\n  headers: { \"Content-Type\": \"application/json; charset=utf-8\" }, // *{}\n  params: { UID: 9873 },\n  data: JSON.stringify(data), // *null\n  maxRedirects: 10, // *5\n  withCredentials: true, // *false, true\n};\n```\n\n### Response object attributes\n\n```js\n{\n  // Contains the status code of the response, e.g. 404 for a not found resource, 200 for a success\n  status: 200,\n  // A message related to the status attribute, e.g. OK for a status 200\n  statusText: \"OK\",\n  // The headers that the server responded with\n  headers: {},\n  // Response content as a string\n  text: \"\",\n  // Response content as JSON\n  json: {},\n  // Response content as Blob on browser and Buffer on Node js\n  arrayBuffer: instance of Blob || instance of Buffer,\n  // Reponse content as Blob\n  blob: instance of Blob\n};\n```\n\n### Errors handling\n\n```js\nregrest.get(\"/McNullington\").catch((error) =\u003e {\n  if (error.response) {\n    /**\n     * A request was made but server responded\n     * with status code out of the 2XX range\n     * `error.response` is an instance of the response object\n     */\n    console.log(error.response.status);\n    console.log(error.response.statusText);\n    console.log(error.response.headers);\n    // ...\n  } else if (error.request) {\n    /**\n     * A request was made, but no response was received\n     * `error.request` is an instance of XMLHttpRequest on browser and an instance of\n     * http.ClientRequest on Node js\n     */\n    console.log(error.request);\n  } else {\n    // Something else happened\n    console.log(error.message);\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftien%2Fregrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftien%2Fregrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftien%2Fregrest/lists"}