client.recordings.each不是Node.js中的函数

时间:2018-08-17 08:23:33

标签: twilio twilio-api

这是我的代码,我已经安装了Twilio和express。但是我似乎无法访问client.recordings。有人可以帮我吗?

var twilio = require('twilio');
const express = require('express');

const app = express();
app.listen(8000, () => {
   console.log('Server started!');
});

app.route('/api/cats/:name').get((req, res) => {
   /*const requestedCatName = req.params['name'];
   res.send({ name: requestedCatName });*/
   const accountSid = 'AC02f0596174c674c015bc697a14f2e41d';
   const authToken = '';
   const client = require('twilio')(accountSid, authToken);
   client.recordings.each({
                    dateCreated: new Date(Date.UTC(2018, 8, 8, 0, 0, 0))
                  },
                      recordings => res.send({ name: recordings.sid })
                  );
}); 

这是我得到的错误

TypeError:client.recordings.each不是函数     在app.route.get(/Users/jerinjacobcherian/Desktop/feedback_backend/server.js:15:21)     在Layer.handle [作为handle_request](/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/layer.js:95:5)     在下一个(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/route.js:137:13)     在Route.dispatch(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/route.js:112:3)     在Layer.handle [作为handle_request](/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/layer.js:95:5)     在/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/index.js:281:22     在param(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/index.js:354:14)     在param(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/index.js:365:14)     在Function.process_params(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/index.js:410:3)     在下一个(/Users/jerinjacobcherian/Desktop/feedback_backend/node_modules/express/lib/router/index.js:275:10)

1 个答案:

答案 0 :(得分:0)

查看语法:

新日期(Date.UTC(2018,8,8,0,0,0))

访问:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC

个月 0到11之间的整数,代表月份。

您是否尝试过: 新日期(Date.UTC(2018, 7 ,8,0,0,0))