sample-code icon indicating copy to clipboard operation
sample-code copied to clipboard

Update a Sync List causes TypeError in javascript: client.sync.services(...).syncLists(...).update is not a function

Open aowolabi opened this issue 6 years ago • 0 comments

I receive the following exception response:

{
    "message": "client.sync.services(...).syncLists(...).update is not a function",
    "name": "TypeError",
    "stack": "TypeError: client.sync.services(...).syncLists(...).update is not a function\n    at Object.exports.handler (/var/task/handlers/<handler-file>.js:77:13)\n    at Object.exports.handler (/var/task/node_modules/enigma-lambda/index.js:306:10)\n    at exports.handler (/var/task/enigma.js:17:9)"
}

This occurs when I attempt to update an existing Sync List. Specifically when calling the following from a Twilio Function:

exports.handler = function(context, event, callback) {
    const client = context.getTwilioClient();
    const TTL_IN_MINUTES = 10;
    const LIST_NAME = 'SomeListName';
    client.sync.services(context.SYNC_SERVICE_SID)
           .syncLists(LIST_NAME)
           .update({ttl: 60 * TTL_IN_MINUTES});
}

This code is pulled directly from the following example:

// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
// DANGER! This is insecure. See http://twil.io/secure
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.sync.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
           .syncLists('MyFirstList')
           .update({ttl: 864000})
           .then(sync_list => console.log(sync_list.uniqueName));

aowolabi avatar Apr 21 '19 21:04 aowolabi