<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
没有合适的资源?快使用搜索试试~ 我知道了~
基于区块链的投票系统全部资料+详细文档.zip
共2001个文件
js:1188个
md:429个
json:293个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 16 浏览量
2024-11-25
21:21:01
上传
评论 2
收藏 13.89MB ZIP 举报
温馨提示
【资源说明】 基于区块链的投票系统全部资料+详细文档.zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于区块链的投票系统全部资料+详细文档.zip (2001个子文件)
tests.c 223KB
secp256k1.c 23KB
tests_exhaustive.c 20KB
bench_internal.c 13KB
org_bitcoin_NativeSecp256k1.c 12KB
bench_ecmult.c 7KB
lax_der_privatekey_parsing.c 5KB
bench_verify.c 4KB
bufferutil.c 4KB
lax_der_parsing.c 4KB
gen_context.c 3KB
bench_recover.c 2KB
bench_ecdh.c 2KB
bench_sign.c 2KB
org_bitcoin_Secp256k1Context.c 404B
.DS_Store 6KB
field_10x26_impl.h 46KB
ecmult_impl.h 46KB
secp256k1.h 31KB
scalar_4x64_impl.h 30KB
group_impl.h 27KB
scalar_8x32_impl.h 26KB
tests_impl.h 20KB
field_5x52_impl.h 16KB
field_5x52_asm_impl.h 13KB
hash_impl.h 13KB
scalar_impl.h 12KB
ecdsa_impl.h 10KB
ecmult_const_impl.h 10KB
field_5x52_int128_impl.h 9KB
ecmult_gen_impl.h 9KB
field_impl.h 9KB
num_gmp_impl.h 8KB
group.h 7KB
main_impl.h 7KB
field.h 6KB
secp256k1_preallocated.h 6KB
util.h 5KB
tests_impl.h 5KB
scalar.h 5KB
secp256k1_recovery.h 5KB
testrand_impl.h 4KB
scalar_low_impl.h 4KB
lax_der_parsing.h 4KB
lax_der_privatekey_parsing.h 4KB
org_bitcoin_NativeSecp256k1.h 4KB
eckey_impl.h 3KB
scratch_impl.h 3KB
bench.h 3KB
num.h 3KB
ecmult_gen.h 3KB
ecmult.h 2KB
main_impl.h 2KB
scratch.h 2KB
secp256k1_ecdh.h 2KB
secp256k1.h 2KB
field_10x26.h 2KB
field_5x52.h 2KB
hash.h 2KB
testrand.h 1KB
eckey.h 1KB
ecdsa.h 1KB
basic-config.h 1KB
ecmult_const.h 848B
scalar_4x64.h 796B
scalar_8x32.h 720B
num_impl.h 690B
num_gmp.h 626B
scalar_low.h 584B
org_bitcoin_Secp256k1Context.h 538B
index.html 2KB
index.html 1KB
index.html 652B
example.html 200B
NativeSecp256k1.java 15KB
NativeSecp256k1Test.java 11KB
Secp256k1Context.java 2KB
NativeSecp256k1Util.java 2KB
web3.min.js 1.13MB
index.js 243KB
_data.js 165KB
psl.js 158KB
psl.min.js 134KB
index.js 103KB
oboe-browser.js 95KB
oboe-node.js 91KB
bn.js 88KB
bn.js 88KB
index.js 73KB
index.js 63KB
swarm.min.js 58KB
index.js 57KB
index.js 50KB
index.min.js 48KB
index.js 46KB
index.js 45KB
index.es.js 44KB
readable.js 42KB
index.js 41KB
index.js 37KB
共 2001 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21
资源评论
Yuki-^_^
- 粉丝: 3112
- 资源: 4587
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 这是用MATLAB编写的sar合成孔径雷达反投影算法的一个实例.zip
- 这些matlab代码通过使用中心有限差分法求解相场方程来模拟晶粒生长.zip
- 针对工程师的SDR的MATLAB实现教材.zip
- 针对MATLAB的AIR Tools II工具箱附带出版物AIR Tools II代数迭代重建方法改进实现Hansen.zip
- Matlab实现RIME-BP霜冰优化BP神经网络多特征分类预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- 针对电子战的发射器探测和地理定位的MATLAB代码.zip
- 阵列信号处理中到达方向DOA估计的MATLAB函数集.zip
- 执行一些从matlab代码到fortran的简单转换.zip
- 执行神经科学数据的信息理论分析的MATLAB工具箱.zip
- 主动学习工具箱的MATLAB.zip
- 准定量子点通道的MATLAB实现.zip
- 指纹识别在运行时使用从移动设备捕获的图像,使用Android和OpenCV构建,也构建在MATLAB中.zip
- 姿态和航向参考系统用MATLAB尽量简单.zip
- Matlab基于BiGRU双向门控循环单元的锂电池寿命预测的详细项目实例(含完整的程序,GUI设计和代码详解)
- 自动编码变分贝叶斯的MATLAB实现.zip
- 自然语言处理工具MATLAB.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功