Coder Social home page Coder Social logo

Comments (5)

jefflinwood avatar jefflinwood commented on June 28, 2024

Hi, looking at your code, I think you might have mixed server side Node.js code:

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,
}
)

with the calls to a Chat Client:

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

The Chat Client gets initialized with an access token - your front end code does not get your Twilio Account Credentials.

from sdk-starter-node.

sergeynilov avatar sergeynilov commented on June 28, 2024

Hello,
Thanks for your feedback, I tried to follow it and got token, which loks like
“eyJ0eXAiO...” and I try next :

...
const Twilio = require('twilio')

console.log('$twilio::')
console.log(Twilio)

console.log('$twilio.Chat::')
console.log(Twilio.Chat)

const client = await Twilio.Chat.Client.create(token)


```I got error :

`TypeError: Cannot read property 'Client' of undefined
`
and in console I see invalid twilio object : https://prnt.sc/w41cc7

I suppose I imported invalid twilio object, but how correctly ?
looks like in the sdk-starter-node-master wasd done in the same way?

package.json :

"axios": "^0.19.0",
"core-js": "^3.3.2",
...
"twilio": "^3.54.0",
"vue": "^2.6.10",
...

from sdk-starter-node.

sergeynilov avatar sergeynilov commented on June 28, 2024

Hello,
Could you please take a look at my error 3 days ago ?
Thanks!

from sdk-starter-node.

sergeynilov avatar sergeynilov commented on June 28, 2024

I try to run this https://www.twilio.com/docs/libraries/node example
in newly created vuejs app

In my first attempts I used twilio parameters of my client.
Now I created new twilio account with parameters : https://prnt.sc/w73idx

Please dont worry that it is unsafe - that is not working account

and in src/App.vue I added twillio code with parameters by button click :

<template>
  <div id="app">
    <button type="button" class="btn btn-primary" @click.prevent="checkTwilioAccount()">
      checkTwilioAccount
    </button>

  </div>
</template>

<script>
export default {
  name: 'App',
  components: {
  },
  
  mounted() {
  }, // mounted() {
  
  methods: {
    
    checkTwilioAccount: function () {
      console.log('checkTwilioAccount::')
      var accountSid = 'AC907b0b422f95363a6508f062385d025b'; // TWILIO_ACCOUNT_SID
      // Your Account SID from www.twilio.com/console
      var authToken = '3de70518507bde59409d8dbcc552ffe8';   // TWILIO_AUTH_TOKEN
      // Your Auth Token from www.twilio.com/console
  
      var twilio = require('twilio');
      console.log('twilio::')
      console.log(twilio)
  
      var client = new twilio(accountSid, authToken);
      console.log('client::')
      console.log(client)
  
  
      client.messages.create({
        body: 'Hello from Node',
        to: '+12345678901',  // Text this number  I LEFT PHONE NUMBER AS ORIGINAL
        from: '+12345678901' // From a valid Twilio number   I LEFT PHONE NUMBER AS ORIGINAL
      })
          .then((message) => console.log(message.sid));
  
    }, // checkTwilioAccount: function () {
  },
  
  }
</script>

and I got error in the browsers console : https://imgur.com/a/YI1aeg6
Did I use invalid parameters? have to make some init procedure under my twilllio account?

In my package.json :

    "core-js": "^3.6.5",
    "twilio": "^3.54.1",
    "vue": "^2.6.11"

Thanks!

from sdk-starter-node.

sergeynilov avatar sergeynilov commented on June 28, 2024

I tried to debug this issue in Twilio.js:258 and found :
https://prnt.sc/w79oys

and ref to undefined element
https://prnt.sc/w79pqi

and I see ref 10 years old
https://prnt.sc/w79q4s
can it be reason of my error and why so ?

I tried version of twilio 3.54.1 (latest) and 3.54.0
but I have the same error and the same data I see debugging...

from sdk-starter-node.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.