listStreams: TypeError: Cannot read properties of undefined (reading 'map')
Closed this issue · 2 comments
tapz commented
The optional chaining is not done properly in the callback and causes a crash.
TypeError: Cannot read properties of undefined (reading 'map')
at callback (/node_modules/opentok/lib/client.js:413:21)
at /node_modules/opentok/lib/client.js:107:7
FIX: ?.map((steam))
-> ?.map?.((stream))
Client.prototype.listStreams = function listStreams(sessionId, cb) {
const url = this.c.apiUrl
+ this.c.endpoints.listStreams
.replace(/<%apiKey%>/g, this.c.apiKey)
.replace(/<%sessionId%>/g, sessionId);
api({
url: url,
method: 'GET',
headers: this.generateHeaders(),
callback: (err, body) => {
cb(err, body?.items?.map((stream) => new Stream(JSON.stringify(stream))) || [])
},
});
};
tapz commented
Would be nice if you could test changes even once before publishing a new version.