<div align="center">
<br>
<br>
<img width="360" src="media/logo.svg" alt="Got">
<br>
<br>
<br>
<p align="center">Huge thanks to <a href="https://moxy.studio"><img src="https://sindresorhus.com/assets/thanks/moxy-logo.svg" valign="middle" width="150"></a> for sponsoring Sindre Sorhus!
</p>
<p align="center"><sup>(they love Got too!)</sup></p>
<br>
<br>
</div>
> Human-friendly and powerful HTTP request library for Node.js
[![Build Status: Linux](https://travis-ci.com/sindresorhus/got.svg?branch=master)](https://travis-ci.com/github/sindresorhus/got)
[![Coverage Status](https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master)
[![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got)
[![Install size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)
[Moving from Request?](documentation/migration-guides.md) [*(Note that Request is unmaintained)*](https://github.com/request/request/issues/3142)
[See how Got compares to other HTTP libraries](#comparison)
For browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the same people.
## Highlights
- [Promise API](#api)
- [Stream API](#streams)
- [Pagination API](#pagination)
- [HTTP2 support](#http2)
- [Request cancelation](#aborting-the-request)
- [RFC compliant caching](#cache-adapters)
- [Follows redirects](#followredirect)
- [Retries on failure](#retry)
- [Progress events](#onuploadprogress-progress)
- [Handles gzip/deflate/brotli](#decompress)
- [Timeout handling](#timeout)
- [Errors with metadata](#errors)
- [JSON mode](#json-mode)
- [WHATWG URL support](#url)
- [HTTPS API](#advanced-https-api)
- [Hooks](#hooks)
- [Instances with custom defaults](#instances)
- [Types](#types)
- [Composable](documentation/advanced-creation.md#merging-instances)
- [Plugins](documentation/lets-make-a-plugin.md)
- [Used by 4K+ packages and 1.8M+ repos](https://github.com/sindresorhus/got/network/dependents)
- [Actively maintained](https://github.com/sindresorhus/got/graphs/contributors)
- [Trusted by many companies](#widely-used)
## Install
```
$ npm install got
```
## Usage
###### Promise
```js
const got = require('got');
(async () => {
try {
const response = await got('https://sindresorhus.com');
console.log(response.body);
//=> '<!doctype html> ...'
} catch (error) {
console.log(error.response.body);
//=> 'Internal server error ...'
}
})();
```
###### JSON
```js
const got = require('got');
(async () => {
const {body} = await got.post('https://httpbin.org/anything', {
json: {
hello: 'world'
},
responseType: 'json'
});
console.log(body.data);
//=> {hello: 'world'}
})();
```
See [JSON mode](#json-mode) for more details.
###### Streams
```js
const stream = require('stream');
const {promisify} = require('util');
const fs = require('fs');
const got = require('got');
const pipeline = promisify(stream.pipeline);
(async () => {
await pipeline(
got.stream('https://sindresorhus.com'),
fs.createWriteStream('index.html')
);
// For POST, PUT, PATCH, and DELETE methods, `got.stream` returns a `stream.Writable`.
await pipeline(
fs.createReadStream('index.html'),
got.stream.post('https://sindresorhus.com')
);
})();
```
**Tip:** `from.pipe(to)` doesn't forward errors. Instead, use [`stream.pipeline(from, ..., to, callback)`](https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback).
**Note:** While `got.post('https://example.com')` resolves, `got.stream.post('https://example.com')` will hang indefinitely until a body is provided. If there's no body on purpose, remember to `.end()` the stream or set the [`body`](#body) option to an empty string.
### API
It's a `GET` request by default, but can be changed by using different methods or via [`options.method`](#method).
**By default, Got will retry on failure. To disable this option, set [`options.retry`](#retry) to `0`.**
#### got(url?, options?)
Returns a Promise giving a [Response object](#response) or a [Got Stream](#streams-1) if `options.isStream` is set to true.
##### url
Type: `string | object`
The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
Properties from `options` will override properties in the parsed `url`.
If no protocol is specified, it will throw a `TypeError`.
**Note:** The query string is **not** parsed as search params. Example:
```js
got('https://example.com/?query=a b'); //=> https://example.com/?query=a%20b
got('https://example.com/', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
// The query string is overridden by `searchParams`
got('https://example.com/?query=a b', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
```
##### options
Type: `object`
Any of the [`https.request`](https://nodejs.org/api/https.html#https_https_request_options_callback) options.
**Note:** Legacy URL support is disabled. `options.path` is supported only for backwards compatibility. Use `options.pathname` and `options.searchParams` instead. `options.auth` has been replaced with `options.username` & `options.password`.
###### method
Type: `string`\
Default: `GET`
The HTTP method used to make the request.
###### prefixUrl
Type: `string | URL`
When specified, `prefixUrl` will be prepended to `url`. The prefix can be any valid URL, either relative or absolute.\
A trailing slash `/` is optional - one will be added automatically.
**Note:** `prefixUrl` will be ignored if the `url` argument is a URL instance.
**Note:** Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. The latter is used by browsers.
**Tip:** Useful when used with [`got.extend()`](#custom-endpoints) to create niche-specific Got instances.
**Tip:** You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`. If the URL doesn't include it anymore, it will throw.
```js
const got = require('got');
(async () => {
await got('unicorn', {prefixUrl: 'https://cats.com'});
//=> 'https://cats.com/unicorn'
const instance = got.extend({
prefixUrl: 'https://google.com'
});
await instance('unicorn', {
hooks: {
beforeRequest: [
options => {
options.prefixUrl = 'https://cats.com';
}
]
}
});
//=> 'https://cats.com/unicorn'
})();
```
###### headers
Type: `object`\
Default: `{}`
Request headers.
Existing headers will be overwritten. Headers set to `undefined` will be omitted.
###### isStream
Type: `boolean`\
Default: `false`
Returns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, options?)`.
###### body
Type: `string | Buffer | stream.Readable` or [`form-data` instance](https://github.com/form-data/form-data)
**Note #1:** The `body` option cannot be used with the `json` or `form` option.
**Note #2:** If you provide this option, `got.stream()` will be read-only.
**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`.
**Note #4:** This option is not enumerable and will not be merged with the instance defaults.
The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
###### json
Type: `object | Array | number | string | boolean | null` *(JSON-serializable values)*
**Note #1:** If you provide thi
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序宠物社区pet-life
共2000个文件
gif:601个
class:491个
java:443个
需积分: 0 15 下载量 65 浏览量
2023-06-29
11:16:01
上传
评论
收藏 40.31MB ZIP 举报
温馨提示
微信小程序宠物社区pet-life
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序宠物社区pet-life (2000个子文件)
001b4b1adbcb10f86a5b5ba2f58998dc1d4bda44 0B
0020c83973ce45874dd17f762139f5a2fc7f46 379B
002de8838052cae84b51c38090b6bc5ce50084 176B
0045df0cc8d27fe77f9e013521202bfbc916a4 4KB
005b6ac5223132073e0183e090c4c02eb9cb87 279B
007eb18d2bbead6ca4f77fd8d6fd329fce5df3 480B
0080d3bcaf6a9ebe0b1bffbc9e96136c6d4bea 50B
00933e55928a972795c9a73812dea7aa424ad0 175B
009cbf7c708a827fe86258a94bde4435df144f 46B
00ac2bc29a2fadca1f0809c1785e6eb86b65aad1 0B
00b34e63d3b3430bc2335bc1445e48f966dda6 839B
00cac1205aaf87d4d0fc5564a368834f985ffa 1KB
00cc8e4900447135da5afb8340f0320969a01e 289B
00f2dfafd849ced83e3d0c569e68d9382ee21d 251B
0136eab5dc2a1e7d735dcf669eb51b34e52b61 249B
016a067247427b95e94b5dcd77e0ab22f95e0a 448B
01770009d2b2ac30a3f7968f22751551978eec 93B
018b03a78ba9b486341d51ceca944ee695b176 263B
019ce3b3680805188840d7fcdeff7b23b8cc77d4 0B
01a88d87b602fe3df62100ea9418caa789c28e 642B
01cc9e94565fe401040342a2b61c2b429aa12c 137B
01cf37fd5afafd015f1a6724ae6ba243ccda6d 79B
01efc160aa64547fb95a8ef75d308eef891cfa 460B
0234230e6b39b919582e2973cc1fca88b3c6e4 427B
02860ad925527e6616f5e39d9cf4aae33a2aaa 580B
0292b74638dbdcd7bdf49eba47c1298e84237e 2KB
02add20b581be471b8d17f887b8e8337070546 194B
02aeff8d37f1d9233cc403704aaac57f1187ff27 200B
02b59f69af36b69018b61b448a25b5230733558e 82B
02bee126af29f5c794f4bad19c1f4fb509f9a2 447B
02c6c4a21bdbbc0430af36e634f0690ee34658 484B
02e76bb16d1b4602a98c59dd0c12a02e32d94a86 0B
03078d1b60e26c91c5401ea77b302e17d931f448 0B
032abb1f03e7e0a5e04ca709e9316d32276d27 119B
0349e52babd14af50f65aa3c3d0374c17c8618ef 0B
035314ed295158c1b697a022bd6ff4bb23a747 510B
035baba27ef7a4ef73c3488232fdb67a9f070c 6KB
0388986fde8c1c96a19bc0f48a8aa01403b82872 0B
0398ccd0f49298b10a3d76a47800d2ebecd49859 0B
03a62d04e0ba10ce2d854953bfdf84640c9444 8KB
03b7d2e801fe821f9bcfdbb66e2b7fc9473126 4KB
03c1fafb68c744b2124ac431ed95732c8f8d25 153B
03da1b580a99f8a44bd1309d77e9e142f538c8 2KB
03e991ae2b61ce6d62d4746567f82dba54d32c 1KB
03f1d57a158042a6c3f0ce254569f37447e845 577B
040bd69aa6a7079017c9be1c9915dc0f1cf51a 54B
0424c12130674de81c5ccb240762600d5579e9f1 434B
0428bb87c90b48771945ac6dd1e96d0004b159 413B
043b68d1c9a81caa5be50d60e138c4ed0f46f0 346B
04412fb242aff1c2673e2a51060450050c2069 2KB
0454f8538e189d19b910dc9cd30d7966643310 335B
0457178dce9684f08ec67dd660b9bf88733d44 81B
04676ff39ef80c74b3a0e6966c5e649c8d017a 410B
04780ecb1a9782dc114c2f3d893cbb5e84b093a1 0B
049b45fc335ce11af619c9af5622fc5cda4621 474B
04a9de4da4038c3d8bb396f6d092ca322f4a45 54B
04b9fd4b08466bf07fe79d15ff827a7326e887 253B
04d8254eaf08feb6b791b66c365b07662bf777 378B
04ee61f6bdc120ade6f3feae374780c053c4c4 116B
05035c2f243f22060007d2dadf882d1a76b474fc 115B
050a748618fa3ea65f9e87ae726a93b70d6f0e 396B
05161a6d1098648b5d2ccd3ff2eb06d61ac03935 0B
051a2f5695b031900998d1efdf5cfbd1e161ce 1KB
054fd0ca037db5bbd60f4551a799e1cbb6835f 54B
05569deb2ae6536037ffcb65491878dfda454335 0B
056763d751cfdc44f2e222e0a3891daa26409e 45B
0580d968ddbe93154d8b0edaf878b9ec6bc81c 4KB
059dabf49802a41e492c9392a085f5ba58ed53 2KB
05ae2f8c4917d95efc8aa01b613e3a954a6706 153B
05b2520d5afe0e31bb26fd380b9104be7f91a504 1KB
05bfd0c6c6b6ad8d3a42541f4d93f861b833d0 1KB
05c4445ea0dd3d02ee4a4a7f3131e869d3780e 1KB
05e9060af61c376dd794a8623f9a32391cec24 3KB
05e9b90c27f899836172a53854725a155ddf8a 45B
05ed51dbeadc3cf02704109c66e36ded8003c974 0B
0603f0837887cf7871a9e9d4a350ccd0589b5b 311B
062d42b29f02edc623834720ef88437b6a3277 857B
063a288a4a6d622ff65844d54a5ad595c80cff37 0B
064f82688cca3dbebf06c8883b1784c6736725 128B
06830ce88bd4f9aacac6f56ce350a383cb77202e 0B
0683362026c7143324e142515310e6f80fde00 2KB
0692175b6dd588c023f25b10798ee25bd6d374 407B
069278fa93ac8cd748ffae138dc2777cd5bd00 450B
069bc8e8b14ef0d48849e1b70e2d91455653be 5KB
069d9625175c5d3756b70ac39fd74d002a961e 2KB
06c8a4ccb58cb2b8c51f25aeee8fedfe513c37 521B
06cb3f4dd17e94a56749b36411bf57f978f569 1KB
06fc4825739224caf820e6edf54e808961b1a6 784B
06fd3a3e99fd34d8286288ed1a9efb72faa9b6 251B
0709750ec1704f0b7e10d4f82f37027346d759 2KB
070a4e63599ee4fde8bcc2a35153a6a9ebd1f6e9 0B
071075c24599ee98254f702bcfc504cdc275a6 681B
071559273ea3bc92b9c0d8ea2e7bab23a7b22b 3KB
07245defc6b9226dad76daea55b88beb31b3bf 1KB
0732ec14eb3bb1cce81f022ad52a95218a8b03e1 0B
0752046714d686d4b76ce039375d75293d74c5 316B
076c7d7376d44bb69f5fd0e465edd8238cd99293 0B
0778f3d8991723fc87fd2f918a6e623362078a 46B
0780156f6179cccc7dfbc809376de40876672038 0B
07a54a6454ffed987f250c13a1d4f45d8fa3f7 867B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
温馨提示
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Matlab实现扩展卡尔曼滤波EKF源码+项目说明+超详细注释.zip
- 学生课程实验的流程.doc
- 微信消息防撤回证据记录软件-大飞哥软件自习室.exe
- 2023-04-06-项目笔记 - 第一百二十阶段 - 4.4.2.118全局变量的作用域-118 -2024.05.01
- 课程设计基于python+mediapipe+opencv手势识别系统源码(含示例图片).zip
- 联想L-IG41M v1.0 BIOS
- 学生课程实验的流程.doc
- 基于MATLAB和Simulink通过正运动学和逆运动学设计了PID控制器.zip
- 文档内置图片提取工具 2.0能够将WORD PDF PPT等文档里面的图片解析并提取出来.exe
- 2023-04-06-项目笔记 - 第一百二十阶段 - 4.4.2.118全局变量的作用域-118 -2024.05.01
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功