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

@@ -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';