I'm trying to implement news feed into my app. Yesterday I wrote this GitHub issue中提取rel中的内容,但今天我尝试在自己的应用中实现它,我得到同样的错误:
TypeError: Cannot read property 'get' of undefined
它引用了这些代码行:
let flatFeed = FeedManager.getNewsFeeds(userId)["timeline_flat"];
flatFeed
.get({})
.then(function(body) {
let activities = body.results;
return StreamBackend.enrichActivities(activities);
})
.then(function(enrichedActivities) {
return res.render("feed", {
location: "feed",
user: req.user,
activities: enrichedActivities,
path: req.url
});
})
.catch(next);
这就是我实例化FeedManager的方式
let stream_node = require("getstream-node");
let FeedManager = stream_node.FeedManager;
我在记录FeedManager.getNewsFeeds(userId))
[ flat: { client:
{ apiKey: 'myapikey',
apiSecret: 'mysecret',
appId: 'myappid',
options: [Object],
version: 'v1.0',
fayeUrl: 'https://faye.getstream.io/faye',
fayeClient: null,
group: 'unspecified',
subscriptions: {},
expireTokens: false,
location: 'us-east',
baseUrl: 'https://us-east-api.stream-io-api.com/api/',
handlers: {},
browser: false,
node: true },
slug: 'flat',
userId: '5a36b5f8c8b6a1a0b5099cc3',
id: 'flat:5a36b5f8c8b6a1a0b5099cc3',
token: '8cQoPLYwlH_qY8vrj7Y8gC7jZ0o',
feedUrl: 'flat/5a36b5f8c8b6a1a0b5099cc3',
feedTogether: 'flat5a36b5f8c8b6a1a0b5099cc3',
signature: 'flat5a36b5f8c8b6a1a0b5099cc3 8cQoPLYwlH_qY8vrj7Y8gC7jZ0o',
notificationChannel: 'site-32687-feed-flat5a36b5f8c8b6a1a0b5099cc3' },
aggregated: { client:
{ apiKey: 'mykey',
apiSecret: 'mysecret',
appId: 'myappid',
options: [Object],
version: 'v1.0',
fayeUrl: 'https://faye.getstream.io/faye',
fayeClient: null,
group: 'unspecified',
subscriptions: {},
expireTokens: false,
location: 'us-east',
baseUrl: 'https://us-east-api.stream-io-api.com/api/',
handlers: {},
browser: false,
node: true },
slug: 'aggregated',
userId: '5a36b5f8c8b6a1a0b5099cc3',
id: 'aggregated:5a36b5f8c8b6a1a0b5099cc3',
token: '1BK-vEXYKYHJNYCMeuf5VHRjeG0',
feedUrl: 'aggregated/5a36b5f8c8b6a1a0b5099cc3',
feedTogether: 'aggregated5a36b5f8c8b6a1a0b5099cc3',
signature: 'aggregated5a36b5f8c8b6a1a0b5099cc3 1BK-vEXYKYHJNYCMeuf5VHRjeG0',
notificationChannel: 'site-32687-feed-aggregated5a36b5f8c8b6a1a0b5099cc3' } ]
跟踪:
TypeError: Cannot read property 'get' of undefined
at exports.feed_get (/Users/brankozivanovic/Desktop/kafici-api/controllers/userController.js:652:5)
at Layer.handle [as handle_request] (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/layer.js:95:5)
at /Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:281:22
at param (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:354:14)
at param (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:410:3)
at next (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:174:3)
at router (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:47:12)
at Layer.handle [as handle_request] (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:317:13)
at /Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:335:12)
at next (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:174:3)
at router (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:47:12)
at Layer.handle [as handle_request] (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:317:13)
at /Users/brankozivanovic/Desktop/kafici-api/node_modules/express/lib/router/index.js:284:7