Files
kami-parse-server/src/cloud-code/HTTPResponse.js
Florent Vilmart 6acb5cee80 ES6-ify
2016-03-08 08:04:34 -05:00

22 lines
441 B
JavaScript

export default class HTTPResponse {
constructor(response) {
this.status = response.statusCode;
this.headers = response.headers;
this.buffer = response.body;
this.cookies = response.headers["set-cookie"];
}
get text() {
return this.buffer.toString('utf-8');
}
get data() {
if (!this._data) {
try {
this._data = JSON.parse(this.text);
} catch (e) {}
}
return this._data;
}
}