From 1d873e969556b3ebf773511fa3332b230afe5f6e Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 14 Nov 2024 06:54:38 +0700 Subject: [PATCH 1/2] fix retrieve call cdr by sid return null --- lib/rest/rest-entity.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rest/rest-entity.js b/lib/rest/rest-entity.js index 47e91db..90b61bd 100644 --- a/lib/rest/rest-entity.js +++ b/lib/rest/rest-entity.js @@ -33,7 +33,8 @@ class RestEntity { async retrieve(sid) { try { const res = await this.get(`Accounts/${this.accountSid}/${this.name}/${sid}`); - return res.length > 0 ? res[0] : null; + //get call by sid will return call cdr as a object and not an array + return res ? res : null; } catch (err) { if (err.statusCode === 404) throw new Error(`${this.name}.retrieve: sid ${sid} not found`); if (err.statusCode !== 204) throw new Error(`${this.name}.retrieve: unexpected status code ${err.statusCode}`); From d3d469734bec12fec88f36171f1d7b41d866c85c Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 14 Nov 2024 06:56:20 +0700 Subject: [PATCH 2/2] fix retrieve call cdr by sid return null --- lib/rest/rest-entity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rest/rest-entity.js b/lib/rest/rest-entity.js index 90b61bd..11adfc0 100644 --- a/lib/rest/rest-entity.js +++ b/lib/rest/rest-entity.js @@ -34,7 +34,7 @@ class RestEntity { try { const res = await this.get(`Accounts/${this.accountSid}/${this.name}/${sid}`); //get call by sid will return call cdr as a object and not an array - return res ? res : null; + return res; } catch (err) { if (err.statusCode === 404) throw new Error(`${this.name}.retrieve: sid ${sid} not found`); if (err.statusCode !== 204) throw new Error(`${this.name}.retrieve: unexpected status code ${err.statusCode}`);