Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

With twilio API in vuejs2 app I got error client.on is not a function #151

@sergeynilov

Description

@sergeynilov

I want to use twilio API in my vuejs2 app looking at demo https://github.com/TwilioDevEd/sdk-starter-node:

I got client object with Twilio credentials, but next I want to assign tokenAboutToExpire with code like :

const client = new Twilio(
    process.env.VUE_APP_TWILIO_API_KEY,
    process.env.VUE_APP_TWILIO_API_SECRET,
    {
        accountSid: process.env.VUE_APP_TWILIO_ACCOUNT_SID,
    }
)
console.log('client::')
console.log(client)
console.log('client.chat::')
console.log(client.chat)

client.on("tokenAboutToExpire", async () => { // Error line
// client.chat.on("tokenAboutToExpire", async () => { // If to uncomment this line 
    const token = await this.fetchChatToken()
    client.updateToken(token)
})

and got error:

Uncaught (in promise) TypeError: client.on is not a function
    at _callee3$ (usersChat.vue?ec5f:264)
    at tryCatch (runtime.js?96cf:63)
    at Generator.invoke [as _invoke] (runtime.js?96cf:293)

and in the console I see that I have client and client.chat : https://prnt.sc/w4frzp
What is wrong?
Is it invalid client object?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions