feat: make BrunoResponse callable to access body data using expressions fixes (#481) (#3710)

* feat: make `BrunoResponse` callable to access body data using expressions
This commit is contained in:
Pragadesh-45
2025-01-28 14:57:00 +05:30
committed by GitHub
parent 956d5a38e9
commit 16e27d2ca4

View File

@@ -1,3 +1,5 @@
const { get } = require('@usebruno/query');
class BrunoResponse {
constructor(res) {
this.res = res;
@@ -6,6 +8,13 @@ class BrunoResponse {
this.headers = res ? res.headers : null;
this.body = res ? res.data : 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() {