Skip to content

Commit 1d7edd3

Browse files
author
Tim Mendoza
committed
Only create conversations client when create_conversation is true
1 parent c20d82e commit 1d7edd3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/serverless/functions/token.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ module.exports.handler = async (context, event, callback) => {
6363

6464
if (create_room) {
6565
const client = context.getTwilioClient();
66-
const conversationsClient = client.conversations.services(CONVERSATIONS_SERVICE_SID);
6766
let room;
6867

6968
try {
@@ -86,6 +85,8 @@ module.exports.handler = async (context, event, callback) => {
8685
}
8786

8887
if (create_conversation) {
88+
const conversationsClient = client.conversations.services(CONVERSATIONS_SERVICE_SID);
89+
8990
try {
9091
// See if conversation already exists
9192
await conversationsClient.conversations(room.sid).fetch();

0 commit comments

Comments
 (0)