Twilio Studio未列出服务
我正在使用Twilio的同步库设置同步应用程序。出于某种原因,RESTAPI方法似乎都不起作用。也就是说,我无法通过运行时函数将任何sync方法获取到console.log()中 但是,我可以使用console.log()纯文本 这是我的密码:Twilio Studio未列出服务,twilio,twilio-functions,twilio-studio,Twilio,Twilio Functions,Twilio Studio,我正在使用Twilio的同步库设置同步应用程序。出于某种原因,RESTAPI方法似乎都不起作用。也就是说,我无法通过运行时函数将任何sync方法获取到console.log()中 但是,我可以使用console.log()纯文本 这是我的密码: exports.handler = function(context, event, callback) { // 0. Init // const phoneNumber = event.phoneNumber; cons
exports.handler = function(context, event, callback) {
// 0. Init
// const phoneNumber = event.phoneNumber;
const issueLimit = 3; // CHANGE IF NEEDED
const listName = 'issues';
const twilioClient = context.getTwilioClient();
// 1. List all lists
twilioClient.sync.services(context.SYNC_SERVICE_SID)
.syncLists
.list({limit: 20})
.then(syncLists => syncLists.forEach(s => console.log(s.sid)));
// 2. return true if quota reached
console.log("Got to here");
// 3. return false
callback(null, undefined);
};
看起来要执行的唯一代码是“console.log(“gottohere”);”。我也没有收到任何错误消息
我们衷心感谢您的指导。当您看到.then()
时,这是一个承诺,您可以在这里阅读更多相关信息
换句话说,JavaScript引擎会先执行步骤2.
,然后执行步骤3.
,而无需等待1.
完成。由于您在步骤3返回回调(null,未定义)代码>您将看不到日志
因此,您必须在中移动callback()
。然后()
,如下所示:
exports.handler = function (context, event, callback) {
// 0. Init
// const phoneNumber = event.phoneNumber;
const issueLimit = 3; // CHANGE IF NEEDED
const listName = 'issues';
const twilioClient = context.getTwilioClient();
// 1. List all lists
twilioClient.sync.services(context.SYNC_SERVICE_SID)
.syncLists
.list({ limit: 20 })
.then(
function (syncLists) {
console.log("Got to here");
syncLists.forEach(s => console.log(s.sid));
callback(null, undefined);
}
);
};
你真棒!非常感谢。