mirror of
https://github.com/usebruno/bruno.git
synced 2025-08-18 19:38:56 +02:00
* feat: make `BrunoResponse` callable to access body data using expressions
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const { get } = require('@usebruno/query');
|
||||||
|
|
||||||
class BrunoResponse {
|
class BrunoResponse {
|
||||||
constructor(res) {
|
constructor(res) {
|
||||||
this.res = res;
|
this.res = res;
|
||||||
@@ -6,6 +8,13 @@ class BrunoResponse {
|
|||||||
this.headers = res ? res.headers : null;
|
this.headers = res ? res.headers : null;
|
||||||
this.body = res ? res.data : null;
|
this.body = res ? res.data : null;
|
||||||
this.responseTime = res ? res.responseTime : null;
|
this.responseTime = res ? res.responseTime : null;
|
||||||
|
|
||||||
|
// Make the instance callable
|
||||||
|
const callable = (...args) => get(this.body, ...args);
|
||||||
|
Object.setPrototypeOf(callable, this.constructor.prototype);
|
||||||
|
Object.assign(callable, this);
|
||||||
|
|
||||||
|
return callable;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatus() {
|
getStatus() {
|
||||||
|
Reference in New Issue
Block a user