Merge pull request #19 from jambonz/fix/retrieve_call

fix retrieve call cdr by sid return null
This commit is contained in:
Dave Horton
2024-11-13 21:23:52 -05:00
committed by GitHub
+2 -1
View File
@@ -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;
} 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}`);