Files
kami-parse-server/src/cloud-code/HTTPResponse.js

22 lines
441 B
JavaScript
Raw Normal View History

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 {
2016-03-08 00:15:17 -05:00
this._data = JSON.parse(this.text);
} catch (e) {}
}
return this._data;
}
2016-03-08 00:15:17 -05:00
}