I'm using heroku to run a node.js app that uses gcloud to create a topic, and then subscribe to it. I'm using the following code, as taken from here: https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.16.0/pubsub
var gcloud = require('gcloud')({
keyFilename: 'pubsub_key.json',
projectId: 'pipedrivesekoul'
});
var pubsub = gcloud.pubsub();
//create a new topic
pubsub.createTopic('projects/pipedrivesekoul/my-new-topic', function(err, topic, apiResponse) {
var topic = pubsub.topic('my-new-topic');
topic.publish({
data: 'New message!'
}, function(err) {console.log});
});
var topic = pubsub.topic('my-new-topic');
// Without specifying any options.
topic.subscribe('newMessages', function(err, subscription, apiResponse) {});
var alltopics = pubsub.getTopics({}, function(err, topics, nextQuery, apiResponse) {});
console.log(pubsub.getTopics({}, function(err, topics, nextQuery, apiResponse) {}));
However, when I deploy on Heroku (https server, registered on Google Console, with the correct APIs deployed and the appropriate key in a json file), instead of seeing a list of topics, it just returns 'undefined':
2015-07-24T18:06:05.321079+00:00 app[web.1]: undefined
2015-07-24T18:06:05.337947+00:00 app[web.1]: Node app is running on port 36252
Not sure why this might be happening and not too sure how to debug this issue. Any suggestions would be greatly appreciated!