Got

为 Node.js 开发的人性化且功能强大的 HTTP 请求库。「Human-friendly and powerful HTTP request library for Node.js」

Github星跟蹤圖

Human-friendly and powerful HTTP request library for Node.js

Build Status: Linux
Coverage Status
Downloads
Install size

Moving from Request? (Note that Request is unmaintained)

See how Got compares to other HTTP libraries

For browser usage, we recommend Ky by the same people.

Highlights

Install

$ npm install got

Usage

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 ...'
	}
})();
Streams
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, and PATCH methods `got.stream` returns a `stream.Writable`
    await pipeline(
        fs.createReadStream('index.html'),
        got.stream.post('https://sindresorhus.com')
    );
})();

Tip: Using from.pipe(to) doesn't forward errors. If you use it, switch to Stream.pipeline(from, ..., to, callback) instead (available from Node v10).

API

It's a GET request by default, but can be changed by using different methods or via options.method.

By default, Got will retry on failure. To disable this option, set options.retry to 0.

got(url?, options?)

Returns a Promise for a response object or a stream if options.isStream is set to true.

url

Type: `string

主要指標

概覽
名稱與所有者sindresorhus/got
主編程語言TypeScript
編程語言TypeScript (語言數: 1)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2014-03-27 22:40:49
推送於2025-07-25 15:59:54
最后一次提交
發布數178
最新版本名稱v14.4.7 (發布於 2025-03-31 20:04:25)
第一版名稱v0.1.0 (發布於 2014-03-27 23:43:16)
用户参与
星數14.7k
關注者數111
派生數1k
提交數1.5k
已啟用問題?
問題數1473
打開的問題數128
拉請求數538
打開的拉請求數0
關閉的拉請求數162
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?