0

I want to use twilio functions & Sync by Runtime Client.

I made function below and got error

exports.handler = function(context, event, callback) {

    let sync = Runtime.getSync();
    sync.lists('list_keys').syncListItems.get(0).then(function(response){
        console.log(response);
        callback(null);
});

Error

{ 
  message: 'sync.lists(...).syncListItems.get(...).then is not a function',     
  name: 'TypeError', 
  stack: 'TypeError: sync.lists(...).syncListItems.get(...).then is not a function
}

when I use all methods remove, get, fetch, I still get the same errors.

How to get key from syncListItems with Runtime client?

Luca Ghersi
  • 3,261
  • 18
  • 32

1 Answers1

0

I work at @Twilio on Functions so I can help you out.

You are looking at the wrong documentation for Sync; you want Sync API documentation: https://www.twilio.com/docs/sync/api/lists. Runtime.getSync() basically returns client.sync.services('default') from the example.

Specifically with your example, the code you are looking for is:

exports.handler = function(context, event, callback) {
    const sync = Runtime.getSync();
    sync.syncLists('list_keys')
        .syncListItems(0)
        .fetch()
        .then(response => {
            console.log(response);
            callback(null);
        });
});

I'm sorry if this was confusing. I'll make sure the documentation on Runtime client is updated so it points to the right page.

Kousha
  • 32,871
  • 51
  • 172
  • 296