<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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本系统前后端分离带小程序 小程序(用户端),后台管理系统(管理员) - 小程序: 登录、注册、宠物领养、发布寻宠、发布领养、宠物社区、宠物评论、发布动态、领养审批、我的收藏、我的关注、举报。 -… 随着移动互联网技术的发展和用户需求的变化,【小程序名称】应运而生,以其轻量化、便捷化的设计理念为用户提供了一种全新的服务模式。作为一款无需下载安装即可使用的应用,【小程序名称】依托于微信庞大的生态系统,让用户在微信内就能轻松实现各种功能操作。 【小程序名称】的核心功能主要集中在【具体服务领域】,例如在线购物、本地生活服务、教育学习或健康管理等。它简化了传统APP繁琐的注册登录流程,支持微信一键授权登录,极大地提升了用户体验。用户通过搜索或扫描二维码,瞬间即可开启使用,享受快速加载、流畅运行的服务。 该小程序界面设计简洁明了,布局合理,易于上手。同时,其特色功能如实时更新的信息推送、个性化推荐以及社交分享功能,让用户能够及时获取所需信息,并方便地将优质内容分享至朋友圈或好友,实现信息的高效传播与互动。 【小程序名称】注重数据安全与隐私保护,严格遵守国家法律法规和微信平台的规定,确保用户数据的安全无虞。此外,其背后的开发团队持续迭代更新,根据用户反馈不断优化产品性能,提升服务质量,致力于打造一个贴近用户需求、充满活力的小程序生态。 总结来说,【小程序名称】凭借其小巧便携、快捷高效的特性,不仅节省了用户的手机存储空间,更为用户提供了无缝衔接的便利服务,是现代生活中不可或缺的一部分,真正实现了“触手可及”的智能生活新体验。只需轻点屏幕,无限精彩尽在掌握之中。
资源推荐
资源详情
资源评论
收起资源包目录
宠物领养社区小程序(源码+数据库) .zip (1707个子文件)
ry.bat 2KB
package.bat 153B
build.bat 109B
run-web.bat 107B
ExcelUtil.class 38KB
Convert.class 13KB
SysMenuServiceImpl.class 13KB
HTMLFilter.class 13KB
SysUserServiceImpl.class 13KB
ReflectUtils.class 11KB
SysDeptServiceImpl.class 10KB
SysRoleServiceImpl.class 9KB
HttpUtils.class 9KB
SysUser.class 8KB
Server.class 8KB
RedisCache.class 8KB
StringUtils.class 8KB
LogAspect.class 8KB
SecurityConfig.class 7KB
SysDictTypeServiceImpl.class 7KB
TokenService.class 7KB
UUID.class 6KB
MyBatisConfig.class 6KB
Apply.class 6KB
ReportController.class 6KB
SysMenu.class 6KB
FileUtils.class 6KB
SysConfigServiceImpl.class 6KB
FileUploadUtils.class 5KB
SysRole.class 5KB
WxUser.class 5KB
PetAdopt.class 5KB
GlobalExceptionHandler.class 5KB
SysLoginService.class 5KB
SysOperLog.class 5KB
RateLimiterAspect.class 5KB
PetFind.class 5KB
SysDept.class 5KB
SysDictData.class 5KB
DruidConfig.class 5KB
RedisConfig.class 5KB
LoginUser.class 5KB
SameUrlDataInterceptor.class 4KB
Base64.class 4KB
DataScopeAspect.class 4KB
DictUtils.class 4KB
PetCyclopediaController.class 4KB
BaseController.class 4KB
AnswerPrizeController.class 4KB
SysRegisterService.class 4KB
PetAdoptController.class 4KB
PetCircleController.class 4KB
ArticleController.class 4KB
CreditsController.class 4KB
CommentController.class 4KB
PetFindController.class 4KB
WxUserController.class 4KB
ApplyController.class 4KB
ChatController.class 4KB
Report.class 4KB
ServletUtils.class 4KB
DateUtils.class 4KB
IpUtils.class 4KB
SysPostServiceImpl.class 4KB
ApplyServiceImpl.class 4KB
ResourcesConfig.class 4KB
SysPost.class 3KB
PermissionService.class 3KB
TreeSelect.class 3KB
SysConfig.class 3KB
Comment.class 3KB
FastJson2JsonRedisSerializer.class 3KB
SpringUtils.class 3KB
UserDetailsServiceImpl.class 3KB
AsyncFactory$1.class 3KB
PetCyclopedia.class 3KB
Article.class 3KB
SysDictType.class 3KB
SysLogininfor.class 3KB
EscapeUtil.class 3KB
RouterVo.class 3KB
ImageUtils.class 3KB
JwtAuthenticationTokenFilter.class 3KB
SysNotice.class 3KB
DataSourceAspect.class 3KB
XssFilter.class 3KB
GenConstants.class 3KB
SysDictDataServiceImpl.class 3KB
BeanUtils.class 3KB
SecurityUtils.class 3KB
SysUserOnlineServiceImpl.class 3KB
LogoutSuccessHandlerImpl.class 3KB
AnswerPrize.class 3KB
Chat.class 3KB
Threads.class 3KB
HttpHelper.class 2KB
CaptchaConfig.class 2KB
BaseEntity.class 2KB
AjaxResult.class 2KB
DruidProperties.class 2KB
共 1707 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
- m0_748129092024-04-09资源是宝藏资源,实用也是真的实用,感谢大佬分享~
JJJ69
- 粉丝: 6169
- 资源: 5789
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功