r2 介绍
r2与 request为同 一个 作者打造,相比于 request更加轻量、专注,基于现代浏览器的 fetch API,基于 promise, 与 asynv/await搭配更佳。
r2是构建在浏览器的Fetch API之上,并为Node.js填充。
API旨在与async / await一起使用,这意味着它们基于promises。
const r2 = require('r2')
let html = await r2('https://www.google.com').text
Simple jsON support.
let obj = {ok: true}
let resp = await r2.put('http://localhost/test.json',{json: obj}).json
Simple headers support.
let headers = {'x-test': 'ok'}
let res = await r2('http://localhost/test',{headers}).response
GitHub: https://github.com/mikeal/r2
网站描述: 一款基于浏览器 Fetch API 的 http 客户端
r2官方网站
官方网站:
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did177013