{"id":18746181,"url":"https://github.com/skoniks/node-request","last_synced_at":"2025-11-23T17:30:16.230Z","repository":{"id":38350442,"uuid":"506422437","full_name":"skoniks/node-request","owner":"skoniks","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-06T12:50:20.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T12:47:34.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skoniks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-22T22:22:11.000Z","updated_at":"2023-11-10T20:22:08.000Z","dependencies_parsed_at":"2022-07-09T04:46:04.009Z","dependency_job_id":null,"html_url":"https://github.com/skoniks/node-request","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoniks%2Fnode-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoniks%2Fnode-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoniks%2Fnode-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoniks%2Fnode-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skoniks","download_url":"https://codeload.github.com/skoniks/node-request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627838,"owners_count":19670961,"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-11-07T16:21:20.252Z","updated_at":"2025-11-23T17:30:16.127Z","avatar_url":"https://github.com/skoniks.png","language":"TypeScript","readme":"# @sknx/request\n\nSimple HTTP client for Node.JS with async/await without dependencies.\n\n# Usage\n\n```javascript\nimport { request } from '@sknx/request';\n\nconst response = await request({\n  url: 'https://google.com',\n  method: 'GET',\n  timeout: 1000,\n  follow: 5,\n\n  // Specify request body\n  headers: {\n    'Content-Type': 'application/json',\n  },\n  body: { foo: 'bar' },\n\n  // Specify response format\n  format: 'json',\n\n  // Validate response statusCode\n  validate: (status) =\u003e statusCode \u003e= 200 \u0026\u0026 statusCode \u003c 300,\n\n  // HTTP / HTTPS Proxy URL\n  proxy: 'http://user:pass@proxy:port',\n});\n\nconsole.log(response.data);\n```\n\nObject **body** is automatically converted into **JSON** string with `'Content-Type'`: `'application/json'` header. If you provide `'Content-Type'` as `'x-www-form-urlencoded'`, body will be converted to **urlencoded** string.\n\nThe following options are available:\n\n- **url**: A string with that represents an absolute URL\n- **method**: `'GET'`, `'PUT'`, or any other ALLCAPS string will be\n  used to set the HTTP method. Defaults to `'GET'`.\n- **format**: Available formats are `'string'`, `'buffer'`, and\n  `'json'`. By default, the response will be returned as `'string'`\n- **headers**: An object can be passed to set request headers.\n- **validate**: Function that defines whether to resolve or reject\n  the promise for a given HTTP response status code.\n- **follow**: A number, that specifies max redirects. If undefined - no redirects will be followed\n- **timeout**: A number, that specifies request timeout in milliseconds\n- **body**: Object, Buffer, or string that will be sent to the server\n- **agent**: A custom agent to be used when performing requests\n- **proxy**: A string with that represents HTTP / HTTPS Proxy URL\n\nResponse Object contains:\n\n- **status**: HTTP status message\n- **statusCode**: HTTP status code\n- **headers**: Response headers Object\n- **data**: Response data in specified format\n- **res**: Raw HTTP response (`IncomingMessage`)\n\nResponse example (without `res`):\n\n```json\n{\n  \"status\": \"OK\",\n  \"statusCode\": 200,\n  \"headers\": {\n    \"access-control-allow-origin\": \"*\",\n    \"content-type\": \"text/plain; charset=utf-8\",\n    \"content-length\": \"13\"\n  },\n  \"data\": \"Hello, world!\"\n}\n```\n\n# Examples\n\n```js\n// Instance request example\nconst instance = new Request({\n  headers: { 'content-type': 'application/json' },\n});\ninstance.defaults.timeout = 5000;\ninstance.request({ url: 'https://ifconfig.me' }).then((response) =\u003e {\n  const { res, ...data } = response;\n  console.log(JSON.stringify(data));\n});\n```\n\n```js\n// StatusCode validation example\nrequest({\n  url: 'https://ifconfig.me',\n  validate: (status) =\u003e status === 400,\n}).catch((error) =\u003e {\n  // Check if validate statusCode error\n  if (Request.isValidateError(error)) {\n    console.log(error.response?.statusCode);\n  }\n});\n```\n\n```js\n// Http Proxy request example\nrequest({\n  url: 'https://ifconfig.me',\n  proxy: 'http://user:pass@proxy:port',\n}).then(({ res, ...data }) =\u003e {\n  console.log(JSON.stringify(data));\n});\n```\n\n# TODO\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoniks%2Fnode-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskoniks%2Fnode-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoniks%2Fnode-request/lists"}