{"id":41952296,"url":"https://github.com/risan/send-request","last_synced_at":"2026-01-25T21:34:24.180Z","repository":{"id":143908010,"uuid":"159053593","full_name":"risan/send-request","owner":"risan","description":"Lightweight HTTP client for Node.","archived":false,"fork":false,"pushed_at":"2020-02-19T19:02:42.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T07:08:54.356Z","etag":null,"topics":["http","http-client","request"],"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/risan.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":"2018-11-25T16:50:23.000Z","updated_at":"2020-02-14T16:43:20.000Z","dependencies_parsed_at":"2023-03-22T11:32:46.618Z","dependency_job_id":null,"html_url":"https://github.com/risan/send-request","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/risan/send-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fsend-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fsend-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fsend-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fsend-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/risan","download_url":"https://codeload.github.com/risan/send-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risan%2Fsend-request/sbom","scorecard":{"id":777176,"data":{"date":"2025-08-11","repo":{"name":"github.com/risan/send-request","commit":"ccdc6e401ebaa2e2078d6ec5d4daabb1a262732e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T03:54:22.272Z","repository_id":143908010,"created_at":"2025-08-23T03:54:22.272Z","updated_at":"2025-08-23T03:54:22.272Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28759412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T20:56:06.009Z","status":"ssl_error","status_checked_at":"2026-01-25T20:54:48.203Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["http","http-client","request"],"created_at":"2026-01-25T21:34:23.552Z","updated_at":"2026-01-25T21:34:24.174Z","avatar_url":"https://github.com/risan.png","language":"JavaScript","readme":"# Send Request\n\n[![Build Status](https://badgen.net/travis/risan/send-request)](https://travis-ci.org/risan/send-request)\n[![Test Covarage](https://badgen.net/codecov/c/github/risan/send-request)](https://codecov.io/gh/risan/send-request)\n[![Latest Version](https://badgen.net/npm/v/send-request)](https://www.npmjs.com/package/send-request)\n\nLightweight HTTP client for Node.\n\n## Installation\n\n```bash\n$ npm install send-request\n```\n\n## Usage\n\nSend HTTP GET request:\n\n```js\nconst sendRequest = require(\"send-request\");\n\n(async () =\u003e {\n  const response = await sendRequest(\"https://httpbin.org/json\");\n\n  console.log(`Status Code: ${response.statusCode}`);\n  console.log({ headers: response.headers });\n  console.log(response.body); // Response as a string\n\n  // If response's content type is a JSON, you get the parsed object.\n  console.log(response.json);\n})();\n```\n\n## Recipes\n\n### Handling Error\n\n```js\nconst sendRequest = require(\"send-request\");\n\n(async () =\u003e {\n  try {\n    const response = await sendRequest(\"https://httpbin.org/status/400\");\n  } catch(error) {\n    console.log(error.message);\n\n    // If it's an HTTP error, it will have response property.\n    if (error.response) {\n      console.log(error.response.statusCode); // 400\n      console.log(error.response.statusMessage);\n      console.log(error.response.headers);\n      console.log(error.response.body);\n    }\n  }\n})();\n```\n\n### Send HTTP POST Request with Body\n\nIf you don't set the `content-type` and `content-length` headers, it will be automatically added. The `content-type` will be set to `application/x-www-form-urlencoded`.\n\n```js\nconst sendRequest = require(\"send-request\");\n\n(async () =\u003e {\n  const response = await sendRequest(\"https://httpbin.org/anything\", {\n    method: \"POST\",\n    body: {\n      foo: \"bar\"\n    }\n  });\n\n  console.log(response.body);\n})();\n```\n\n### Send HTTP Request with JSON Body\n\nIf you don't set the `content-type` and `content-length` headers, it will be automatically added. The `content-type` will be set to `application/json`.\n\n```js\nconst sendRequest = require(\"send-request\");\n\n(async () =\u003e {\n  const response = await sendRequest(\"https://httpbin.org/anything\", {\n    method: \"POST\",\n    body: {\n      foo: \"bar\"\n    },\n    json: true // Must be set to true\n  });\n\n  console.log(response.json);\n})();\n```\n\n### Sending File with FormData\n\nYou pass the [`FormData`](https://github.com/form-data/form-data) instance as a `body`. If you don't set the `content-type` and `content-length` headers, it will be automatically added. The `content-type` will be set to `multipart/form-data`. The `json` option won't have any effect.\n\n```js\nconst fs = require(\"fs\");\nconst sendRequest = require(\"send-request\");\nconst FormData = require(\"form-data\");\n\n(async () =\u003e {\n  const file = fs.createReadStream(\"./test.txt\");\n\n  const form = new FormData();\n  form.append(\"foo\", \"bar\");\n  form.append(\"my_file\", file);\n\n  const response = await sendRequest(\"https://httpbin.org/anything\", {\n    method: \"POST\",\n    body: form\n  });\n\n  console.log(response);\n})();\n```\n\n## API\n\n```js\nsendRequest(url, [{\n  method,\n  headers,\n  auth: {\n    username,\n    password\n  },\n  body,\n  json,\n  encoding\n}])\n```\n\n### Parameters\n\n* **`url`** (*`String`*): The URL to send the HTTP request to.\n* **`method`** (optional *`String`*): The HTTP method to use, default to `GET`.\n* **`headers`** (optional *`Object`*): The request headers to send.\n* **`auth.username`** (optional *`String`*): The username for HTTP basic auth.\n* **`auth.password`** (optional *`String`*): The password for HTTP basic auth.\n* **`body`** (optional *`Object|FormData`*): The request body to send. It can be a plain JavaScript object or an instance of [`FormData`](https://github.com/form-data/form-data).\n* **`json`** (optional *Boolean*): Set to `true` if you want to send the request body with `application/json` content type. Default to `false`, which means that the request body will be sent as `application/x-www-form-urlencoded`. Note that you can still override the content type using the `headers` option.\n* **`encoding`** (optional *`String`*|*`Null`*): The encoding to decode the incoming response. If set to `null`, the response's body will be a `Buffer` instance.\n\n### Returns\n\nIt returns a `Promise` which when resolved contains a response object. Here's an example of a reponse object:\n\n```js\n{\n  statusCode: 200,\n  statusMessage: \"OK\",\n  headers: {\n    \"content-type\": \"application/json\"\n  },\n  body: '{\"foo\": \"bar\"}',\n  json: {\n    foo: \"bar\"\n  }\n}\n```\n\n* **`statusCode`** (*Number*): The HTTP status code.\n* **`statusMessage`** (*Number*): The HTTP status message (reason phrase).\n* **`headers`** (*Object*): The response's headers.\n* **`body`** (*String*): The response's body.\n* **`json`** (*Object*): The parsed JSON body. It only exist if the response's content type is `application/json`.\n\n## License\n\n[MIT](https://github.com/risan/send-request/blob/master/LICENSE) © [Risan Bagja Pradana](https://risanb.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisan%2Fsend-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frisan%2Fsend-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisan%2Fsend-request/lists"}