mirror of
https://github.com/Wessel/wumpfetch.git
synced 2026-07-18 06:13:56 +02:00
Some code base improvements
This commit is contained in:
@@ -2,7 +2,6 @@ module.exports = class WumpResponse {
|
||||
constructor (res) {
|
||||
this.body = Buffer.alloc(0);
|
||||
this.coreRes = res;
|
||||
|
||||
this.headers = res.headers;
|
||||
this.statusCode = res.statusCode;
|
||||
}
|
||||
@@ -12,19 +11,11 @@ module.exports = class WumpResponse {
|
||||
}
|
||||
|
||||
parse () {
|
||||
if (this.headers['content-type'] === 'application/json') return JSON.parse(this.body);
|
||||
if (this.headers['content-type'].includes('application/json')) return JSON.parse(this.body);
|
||||
else return this.body.toString();
|
||||
}
|
||||
|
||||
buffer () {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
text () {
|
||||
return this.body.toString();
|
||||
}
|
||||
|
||||
json () {
|
||||
return JSON.parse(this.body);
|
||||
}
|
||||
text () { return this.body.toString(); }
|
||||
json () { return JSON.parse(this.body); }
|
||||
buffer () { return this.body; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user