我正在使用Twilio Functions,我正在尝试使用Sync Documents,但我一直收到此错误:context.getTwilioClient(...).document is not a function
exports.handler = function(context, event, callback) {
context.getTwilioClient().document('data').then(function(doc) {..});
};
答案 0 :(得分:0)
Twilio开发者传道者在这里。
正如Andy所说,您从context.getTwilioClient()
检索的客户端是一个通用的Twilio REST API客户端,可以访问所有资源。
要get your document,您需要遍历客户端中的对象并获取service的句柄。您需要同步服务SID,理想情况下在您的环境变量中,代码如下所示:
const client = context.getTwilioClient();
const service = client.sync.services(process.env.SYNC_SERVICE_SID);
service.document('data').fetch().then(function(doc) {
// do something with the document.
});
让我知道这是否有帮助。