mirror of
https://github.com/status-im/status-go.git
synced 2025-01-11 07:07:24 +00:00
b50c46caa8
* Commit initial change for settimeout/setinterval * Add initial tests for jail setTimeout/setInterval * Add ottoext dependency * Add fetch jail test with function * Add dependencies of fetch from ottoext * Refactor with regards to PR review * Refactor with regards to PR review * Fix syntax errors * Fix missing return statement
24 lines
515 B
JavaScript
24 lines
515 B
JavaScript
const Headers = require('./headers');
|
|
|
|
export default class Response {
|
|
bodyUsed = true;
|
|
|
|
_body = null;
|
|
|
|
constructor(body, {status=200, statusText='OK', headers={}}={}) {
|
|
this.headers = new Headers(headers);
|
|
this.ok = status >= 200 && status < 300;
|
|
this.status = status;
|
|
this.statusText = statusText;
|
|
this.type = this.headers.get('content-type');
|
|
}
|
|
|
|
text() {
|
|
return new Promise(resolve => resolve(this._body));
|
|
}
|
|
|
|
json() {
|
|
return this.text().then(d => JSON.parse(d));
|
|
}
|
|
}
|