{"id":19073509,"url":"https://github.com/then/then-request","last_synced_at":"2025-12-17T10:04:20.235Z","repository":{"id":13964972,"uuid":"16665460","full_name":"then/then-request","owner":"then","description":"A request library that returns promises, inspired by request","archived":false,"fork":false,"pushed_at":"2024-01-26T14:25:06.000Z","size":109,"stargazers_count":241,"open_issues_count":12,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-12T16:29:29.961Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/then.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","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":"2014-02-09T11:50:03.000Z","updated_at":"2025-09-28T05:25:58.000Z","dependencies_parsed_at":"2024-06-18T12:31:31.840Z","dependency_job_id":"8cca88a2-ef41-453c-aec4-a773f3c4e80e","html_url":"https://github.com/then/then-request","commit_stats":{"total_commits":77,"total_committers":9,"mean_commits":8.555555555555555,"dds":0.2987012987012987,"last_synced_commit":"8f1b3a026f4f4acfdb643ae5cdc59a6d8425d2da"},"previous_names":["then/request"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/then/then-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/then%2Fthen-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/then%2Fthen-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/then%2Fthen-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/then%2Fthen-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/then","download_url":"https://codeload.github.com/then/then-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/then%2Fthen-request/sbom","scorecard":{"id":879357,"data":{"date":"2025-08-11","repo":{"name":"github.com/then/then-request","commit":"8f1b3a026f4f4acfdb643ae5cdc59a6d8425d2da"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"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":"Code-Review","score":1,"reason":"Found 3/28 approved changesets -- score normalized to 1","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":"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":"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":"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":"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":"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":"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":"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":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/then/.github/SECURITY.md:1","Info: Found linked content: github.com/then/.github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/then/.github/SECURITY.md:1","Info: Found text in security policy: github.com/then/.github/SECURITY.md:1"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 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-24T07:27:52.564Z","repository_id":13964972,"created_at":"2025-08-24T07:27:52.564Z","updated_at":"2025-08-24T07:27:52.564Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285890392,"owners_count":27249010,"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","status":"online","status_checked_at":"2025-11-23T02:00:06.149Z","response_time":135,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-09T01:47:11.357Z","updated_at":"2025-12-17T10:04:20.216Z","avatar_url":"https://github.com/then.png","language":"TypeScript","readme":"# then-request\n\nA request library that returns promises and supports both browsers and node.js\n\n[![Build Status](https://img.shields.io/travis/then/then-request/master.svg)](https://travis-ci.org/then/then-request)\n[![Dependency Status](https://img.shields.io/david/then/then-request.svg)](https://david-dm.org/then/then-request)\n[![NPM version](https://img.shields.io/npm/v/then-request.svg)](https://www.npmjs.org/package/then-request)\n\n\u003ca target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/gg9sZwctSLxyov1sJwW6pfyS/then/then-request'\u003e\n  \u003cimg alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/gg9sZwctSLxyov1sJwW6pfyS/then/then-request.svg' /\u003e\n\u003c/a\u003e\n\n## Installation\n\n    npm install then-request\n\n## Usage\n\n`request(method, url, options, callback?)`\n\nThe following examples all work on both client and server.\n\n```js\nvar request = require('then-request');\n\nrequest('GET', 'http://example.com').done(function (res) {\n  console.log(res.getBody());\n});\n\nrequest('POST', 'http://example.com/json-api', {json: {some: 'values'}}).getBody('utf8').then(JSON.parse).done(function (res) {\n  console.log(res);\n});\n\nvar FormData = request.FormData;\nvar data = new FormData();\n\ndata.append('some', 'values');\n\nrequest('POST', 'http://example.com/form-api', {form: data}).done(function (res) {\n  console.log(res.getBody());\n});\n```\n\nOr with ES6\n\n```js\nimport request, {FormData} from 'then-request';\n\nrequest('GET', 'http://example.com').done((res) =\u003e {\n  console.log(res.getBody());\n});\n\nrequest('POST', 'http://example.com/json-api', {json: {some: 'values'}}).getBody('utf8').then(JSON.parse).done((res) =\u003e {\n  console.log(res);\n});\n\nvar FormData = request.FormData;\nvar data = new FormData();\n\ndata.append('some', 'values');\n\nrequest('POST', 'http://example.com/form-api', {form: data}).done((res) =\u003e {\n  console.log(res.getBody());\n});\n```\n\n**Method:**\n\nAn HTTP method (e.g. `GET`, `POST`, `PUT`, `DELETE` or `HEAD`). It is not case sensitive.\n\n**URL:**\n\nA url as a string (e.g. `http://example.com`). Relative URLs are allowed in the browser.\n\n**Options:**\n\n - `qs` - an object containing querystring values to be appended to the uri\n - `headers` - http headers (default: `{}`)\n - `body` - body for PATCH, POST and PUT requests.  Must be a `Buffer`, `ReadableStream` or `String` (only strings are accepted client side)\n - `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json`.  Does not have any affect on how the response is treated.\n - `form` - You can pass a `FormData` instance to the `form` option, this will manage all the appropriate headers for you.  Does not have any affect on how the response is treated.\n - `cache` - only used in node.js (browsers already have their own caches) Can be `'memory'`, `'file'` or your own custom implementaton (see https://github.com/ForbesLindesay/http-basic#implementing-a-cache).\n - `followRedirects` - defaults to `true` but can be explicitly set to `false` on node.js to prevent then-request following redirects automatically.\n - `maxRedirects` - sets the maximum number of redirects to follow before erroring on node.js (default: `Infinity`)\n - `allowRedirectHeaders` (default: `null`) - an array of headers allowed for redirects (none if `null`).\n - `gzip` - defaults to `true` but can be explicitly set to `false` on node.js to prevent then-request automatically supporting the gzip encoding on responses.\n - `agent` - (default: `false`) - An `Agent` to controll keep-alive. When set to `false` use an `Agent` with default values.\n - `timeout` (default: `false`) - times out if no response is returned within the given number of milliseconds.\n - `socketTimeout` (default: `false`) - calls `req.setTimeout` internally which causes the request to timeout if no new data is seen for the given number of milliseconds.  This option is ignored in the browser.\n - `retry` (default: `false`) - retry GET requests.  Set this to `true` to retry when the request errors or returns a status code greater than or equal to 400 (can also be a function that takes `(err, req, attemptNo) =\u003e shouldRetry`)\n - `retryDelay` (default: `200`) - the delay between retries (can also be set to a function that takes `(err, res, attemptNo) =\u003e delay`)\n - `maxRetries` (default: `5`) - the number of times to retry before giving up.\n\n\n**Returns:**\n\nA [Promise](https://www.promisejs.org/) is returned that eventually resolves to the `Response`.  The resulting Promise also has an additional `.getBody(encoding?)` method that is equivallent to calling `.then(function (res) { return res.getBody(encoding?); })`.\n\n### Response\n\nNote that even for status codes that represent an error, the promise will be resolved as the request succeeded.  You can call `getBody` if you want to error on invalid status codes.  The response has the following properties:\n\n - `statusCode` - a number representing the HTTP status code\n - `headers` - http response headers\n - `body` - a string if in the browser or a buffer if on the server\n - `url` - the URL that was requested (in the case of redirects on the server, this is the final url that was requested)\n\nIt also has a method `getBody(encoding?)` which looks like:\n\n```js\nfunction getBody(encoding) {\n  if (this.statusCode \u003e= 300) {\n    var err = new Error('Server responded with status code ' + this.statusCode + ':\\n' + this.body.toString(encoding));\n    err.statusCode = this.statusCode;\n    err.headers = this.headers;\n    err.body = this.body;\n    throw err;\n  }\n  return encoding ? this.body.toString(encoding) : this.body;\n}\n```\n\n### FormData\n\n```js\nvar FormData = require('then-request').FormData;\n```\n\nForm data either exposes the node.js module, [form-data](https://www.npmjs.com/package/form-data), or the builtin browser object [FormData](https://developer.mozilla.org/en/docs/Web/API/FormData), as appropriate.\n\nThey have broadly the same API, with the exception that form-data handles node.js streams and Buffers, while FormData handles the browser's `File` Objects.\n\n## License\n\n  MIT\n","funding_links":[],"categories":["24. Ajax模块","24. 前后端交互"],"sub_categories":["13.20 视差滚动(Parallax Scrolling) ###","24.1 Ajax模块"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthen%2Fthen-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthen%2Fthen-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthen%2Fthen-request/lists"}