0
votes

I'm trying to display Twilio data in my template view, list all of the messages sent using the Twilio API for my account. All this in Nativescript-Vue. My code looks like this

<template>
  <Page>
    <ActionBar title="API TEST/>
      <ScrollView>
        <StackLayout>
          <StackLayout :key="message.sid" v-for="message in myMessages">
            <Label :text="message.body" />
            <Label :text="message.from" />
            <Label :text="message.to " />
          </StackLayout>
        </StackLayout>
    </ScrollView>
  </Page>
</template>

<script>
  const Twilio = require('twilio');
  const client = new Twilio("[my accountSid]","[my authToken]");

  export default {
   data() {
     return {
       myMessages: []
     }
   },

   created() {
     this.getList();
   },

   methods: 
     {
      getList() {
        client.messages
          .list()
          .then(messages => messages.forEach(m => this.myMessages.push(m))
          )
          .catch(err => console.error(err));
       }
     }
  }
</script>

When I run tns run android I get the following error

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication:com.tns.NativeScriptException: Error calling module function
System.err: TypeError: Cannot read property 'split' of undefined
System.err: File: (file:///node_modules\pbkdf2\lib\default-encoding.js:6:47)

Thanks in advance for the help!

2
I don't think this package is compatible with {N}, only CommonJS modules work with {N} runtime.Manoj

2 Answers

0
votes

Since its occurring in pbkdf2, a cryptographic library, I would wager its an issue with your Twilio authentication information. Make sure you are using the correct values.

I would verify this by isolating the twilio code into its own small testable snippet.

0
votes

It seems that there is some bug in the pbkdf2 default-encoding.js. You may need to edit the module library

Try open the node_modules\pbkdf2\lib\default-encoding.js:6:47 like the error suggest and add this on top of the file

var process = require('process')

If error still there after adding the line, you may need to post an issue on their github