mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-07-27 02:20:53 +02:00
update docs
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
dist/
|
dist/
|
||||||
docs/
|
|
||||||
__test__/
|
__test__/
|
||||||
examples/
|
examples/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
README.md
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
index.d.ts
|
index.d.ts
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|||||||
93
README.md
93
README.md
@@ -8,105 +8,18 @@
|
|||||||
|
|
||||||
Wumpfetch is a fast, lightweight and easy to use HTTP client for Node.JS.
|
Wumpfetch is a fast, lightweight and easy to use HTTP client for Node.JS.
|
||||||
|
|
||||||
> [`Typings`](https://github.com/PassTheWessel/wumpfetch-typings) **|** [`GitHub`](https://github.com/PassTheWessel/wumpfetch) **|** [`NPM`](https://npmjs.com/package/wumpfetch)
|
> [`GitHub`](https://github.com/PassTheWessel/wumpfetch) **|** [`NPM`](https://npmjs.com/package/wumpfetch)
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
Wumpfetch can be installed with any package manager that supports the NPM registry, but the ones listed below are the most used ones.
|
|
||||||
```sh
|
```sh
|
||||||
$ yarn add wumpfetch # Install w/ Yarn
|
$ yarn add wumpfetch # Install w/ Yarn
|
||||||
$ npm i wumpfetch # Install w/ NPM
|
$ npm i wumpfetch # Install w/ NPM
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example usage
|
## Documentation
|
||||||
##### Code
|
Documentation can be found at [https://github.com/PassTheWessel/wumpfetch/wiki](https://github.com/PassTheWessel/wumpfetch/wiki)
|
||||||
```js
|
|
||||||
const w = require('wumpfetch');
|
|
||||||
|
|
||||||
;(async() => {
|
|
||||||
const r = await w('https://aws.random.cat/meow').send();
|
|
||||||
|
|
||||||
console.log(r.json());
|
|
||||||
});
|
|
||||||
```
|
|
||||||
##### Result
|
|
||||||
```sh
|
|
||||||
$ 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**:
|
|
||||||
```js
|
|
||||||
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**:
|
|
||||||
```sh
|
|
||||||
$ 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`
|
|
||||||
```js
|
|
||||||
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 | [🔩](https://npmjs.com/package/boats.js) [⚖](https://packagephobia.now.sh/result?p=boats.js) [📂](https://github.com/DiscordBoats/boats.js) [👾](https://boats.js.org/?referrer=wumpfetch)
|
|
||||||
| qtradio.js | API wrapper for qtradio.moe made in JavaScript | [🔩](https://npmjs.com/package/qtradio.js) [⚖](https://packagephobia.now.sh/result?p=qtradio.js) [📂](https://github.com/auguwu/qtradio.js) [👾](https://qtradio.moe/?referrer=wumpfetch)
|
|
||||||
| cafebot.js | CafeBot.xyz API Wrapper made in JS | [🔩](https://npmjs.com/package/cafebot.js) [⚖](https://packagephobia.now.sh/result?p=cafebot.js) [📂](https://github.com/DopeDealers/cafebot.js) [👾](https://cafebot.xyz/?referrer=wumpfetch)
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[](https://app.fossa.io/projects/git%2Bgithub.com%2FPassTheWessel%2Fwumpfetch?ref=badge_large)
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2FPassTheWessel%2Fwumpfetch?ref=badge_large)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 6.7 KiB |
Reference in New Issue
Block a user