2019-04-12 19:41:25 +02:00
2019-04-12 18:34:09 +02:00
2019-04-05 17:15:24 +02:00
2019-04-12 17:00:34 +02:00
2019-04-07 11:58:42 +01:00
2019-04-12 18:34:09 +02:00
2019-04-12 19:36:48 +02:00
2019-04-12 19:36:48 +02:00
2019-04-12 10:24:35 +02:00
2019-04-11 18:28:38 +01:00
2019-03-29 14:06:46 -07:00
2019-04-11 18:28:38 +01:00
2019-04-12 19:41:25 +02:00
2019-04-12 18:34:09 +02:00

Wumpfetch - A fast and easy to use HTTP client

MIT License Travis Build Status

Wumpfetch is a fast, lightweight and easy to use HTTP client for Node.JS.

Typings | GitHub | NPM


Installing

Wumpfetch can be installed with any package manager that supports the NPM registry, but the ones listed below are the most used ones.

$ yarn add wumpfetch # Install w/ Yarn
$ npm i wumpfetch # Install w/ NPM

Example usage

Code
const w = require('wumpfetch');

;(async() => {
	const r = await w('https://aws.random.cat/meow').send();

	console.log(r.json());
});
Result
$ node test.js
{ file: 'https://purr.objects-us-east-1.dream.io/i/100_-_rURSo7L.gif' }

Sending data in a JSON body to a server

Getting a response from a REST API

Code:

const w = require('wumpfetch');

// Using an URL and custom options
;(async() => {
  let req = await w('https://aws.random.cat/meow', {
    chaining: false,
    headers: {
      'User-Agent': 'Project/0.0.1'
    }
  });
  // Only URL
  req = await w('https://aws.random.cat/meow', { chaining: false });
  // Only options
  req = await w({
    url: 'https://aws.random.cat/meow',
    chaining: false,
    headers: {
      'User-Agent': 'Project/0.0.1'
    }
  });
  
  console.log(req.json());
})();

Result:

$ node test.js
{ file: 'https://purr.objects-us-east-1.dream.io/i/100_-_rURSo7L.gif' }

Chaining methods

You can also chain methods by adding chaining: true to options

const w = require('wumpfetch');

;(async() => {
	const r = await w('https://my-site.com/postboi', { method: 'POST' })
		.timeout(1000) // Set a 1s timeout
		.query('video', 'wumpboye') // Add a query
		.header({ 'Authorization': 'Pablito' }) // Set a header
		.body({ x: 'y', z: 1, beep: 'boop', chocolate: true }) // Send a JSON body
		.send(); // Finish the chain by sending the rquest

	console.log(r.json()); // Returns the response in a JSON format
})();

Projects using Wumpfetch

If you want your own project listed, either create a pull request or an issue with the following content:

  • Project name
  • a short description of your package

Also add the following if your project is a package/module/library:

  • NPM link (🔩)
  • Packagephobia link (⚖)
  • GitHub repository link (📂)
  • Optional: A website link (👾)
Project Name Short description Links
boats.js The official discord.boats API wrapper for NodeJS 🔩 📂 👾
qtradio.js API wrapper for qtradio.moe made in JavaScript 🔩 📂 👾
cafebot.js CafeBot.xyz API Wrapper made in JS 🔩 📂 👾

License

FOSSA Status

Description
🚀🔗 A modern, lightweight, fast and easy to use Node.js HTTP client
Readme MIT 163 KiB
Languages
JavaScript 96.9%
TypeScript 3.1%