项目作者: dragonfire535

项目描述 :
A wrapper for node-fetch that makes it appear like superagent.
高级语言: JavaScript
项目地址: git://github.com/dragonfire535/node-superfetch.git
创建时间: 2018-06-09T23:36:10Z
项目社区:https://github.com/dragonfire535/node-superfetch

开源协议:Other

下载


node-superfetch

Downloads
Version

node-superfetch is a tiny little wrapper for Node.js’ fetch API that makes it
look like you are using superagent.

Basic Usage

  1. const request = require('node-superfetch');
  2. try {
  3. const { body } = await request.get('https://registry.npmjs.com/node-superfetch');
  4. console.log(body);
  5. } catch (err) {
  6. console.error(err);
  7. }

Usage is basically that of superagent or snekfetch, and implements the same HTTP
methods, as well as functions like query (sets query parameters), set (sets
headers), send (for adding POST data and such), attach (for sending
FormData), redirects (for setting the allowed number of redirects), and
agent (for setting the HTTP agent). end is also supported for callbacks.

Additionally, you can also use the noResultData option to get everything
except the actual result data of the request. This is essentially doing the
request without calling any methods to parse the result data.

  1. const { headers, url } = await request.get('https://registry.npmjs.com/node-superfetch', { noResultData: true });
  2. console.log(url); // should log https://registry.npmjs.com/node-superfetch