Fixed hopefully

This commit is contained in:
Wessel T
2019-04-06 23:21:45 +02:00
parent 7ee8d3bf6b
commit 054f1832b6
4 changed files with 8 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
# Wumpfetch
> A lightweight and fast Node.js HTTP client which can be used in various ways
> [GitHub](https://www.github.com/PassTheWessel/wumpfetch) **|** [NPM](https://www.npmjs.com/package/wumpfetch)
> [Typings](https://www.github.com/PassTheWessel/wumpfetch-typings) [GitHub](https://www.github.com/PassTheWessel/wumpfetch) **|** [NPM](https://www.npmjs.com/package/wumpfetch)
## Installing
```sh

View File

@@ -3,6 +3,7 @@ const wump = require('../lib');
console.log(`Using wumpfetch v${wump.version} [${wump.userAgent}]\n\n`);
;(async() => {
const requests = [
await wump({ url: 'https://jsonplaceholder.typicode.com/todos/1', parse: 'json' }).send(),

View File

@@ -23,7 +23,7 @@ module.exports = class WumpRequest {
'm': typeof o === 'string' ? o : obj && o.method ? o.method : 'GET',
'url': typeof url === 'string' ? new URL(url) : obj && typeof o.url === 'string' ? new URL(o.url) : url,
'SDA': obj && typeof o.sendDataAs === 'string' ? o.sendDataAs : obj && o.data && typeof o.data === 'object' ? 'json' : undefined,
'data': obj && o.data ? o.data : obj && o.json ? o.json : obj && o.form ? stringify(o.form) : undefined,
'data': obj && o.body ? o.body : obj && o.data ? o.data : obj && o.json ? o.json : obj && o.form ? stringify(o.form) : undefined,
'parse': obj && o.parse ? o.parse : undefined,
'follow': !!(obj && o.followRedirects),
'rHeaders': obj && typeof o.headers === 'object' ? o.headers : {},
@@ -95,7 +95,7 @@ module.exports = class WumpRequest {
return new Promise((resolve, reject) => {
if (this.o.data) {
if (!this.o.rHeaders.hasOwnProperty('user-agent')) {
this.o.rHeaders['User-Agent'] = w.userAgent;
this.o.rHeaders['User-Agent'] = w.userAgent || 'Wumpfetch/2.0.1 (https://github.com/PassTheWessel/wumpfetch)';
}
if (this.o.SDA === 'json' && !this.o.rHeaders.hasOwnProperty('content-type')) this.o.rHeaders['Content-Type'] = 'application/json';

View File

@@ -1,6 +1,6 @@
{
"name": "wumpfetch",
"version": "0.2.0",
"version": "0.2.1",
"description": "🚀 A lightweight and fast Node.JS HTTP Client",
"author": "Wessel \"wesselgame\" T <discord@go2it.eu>",
"license": "MIT",
@@ -32,5 +32,8 @@
"gulp": "^4.0.0",
"gulp-concat": "^2.6.1",
"gulp-minify": "^3.1.0"
},
"dependencies": {
"wumpfetch": "^0.2.0"
}
}