Add chaining option and update README

This commit is contained in:
Wessel Tip
2019-04-12 18:23:18 +02:00
parent 8848ec10c8
commit c581ae33b0
3 changed files with 59 additions and 36 deletions

View File

@@ -23,7 +23,8 @@ module.exports = class WumpRequest {
'url': typeof url === 'string' ? new u.URL(url) : obj && typeof o.url === 'string' ? new u.URL(o.url) : url,
'SDA': obj && typeof o.sendDataAs === 'string' ? o.sendDataAs : obj && o.data && typeof o.data === 'object' ? 'json' : undefined,
'data': obj && o.body ? o.body : obj && o.data ? o.data : obj && o.json ? o.json : obj && o.form ? qs.stringify(o.form) : undefined,
'parse': obj && o.parse ? o.parse : undefined,
'parse': obj && o.parse ? o.parse : undefined,
'chain': !!(obj && o.chaining),
'follow': !!(obj && o.followRedirects),
'rHeaders': obj && typeof o.headers === 'object' ? o.headers : {},
'streamed': !!(obj && o.streamed),
@@ -34,8 +35,10 @@ module.exports = class WumpRequest {
if (typeof o.core === 'object') Object.keys(o.core).forEach((v) => this.option(v, o.core[v]));
if (!this.o.chain) return this.send();
return this;
}
}
query (a, b) {
if (typeof a === 'object') Object.keys(a).forEach((v) => this.o.url.searchParams.append(v, a[v]));