sindresorhus/got: 🌐 Human-friendly and powerful HTTP request library for Node.js
Node.js 的一個 Human-friendly 的強大 HTTP request library
根據官網的表,got
支援 HTTP/2,在 Node.js 15.10.0 以上的版本中可以使用。
Got 有一個專門的選項來處理 JSON playload。
具體的說,got 有一個會回傳 Promise<T>
的 .json<T>()
函數可以用來處理 json。
import got from 'got';
const {data} = await got.post('https://httpbin.org/anything', {
json: {
hello: 'world'
}
}).json();
console.log(data);
//=> {"hello": "world"}