Cloud code functions not getting called
I have set up parse-server on Heroku, but I am having trouble with the cloud code. I used the parse-server-example, and replaced the contents of main.js with my own:
console.log('##### TEST');
Parse.Cloud.afterSave('SomeClass', function(request) {
console.log('##### INSIDE AFTER SAVE');
});
And this is my parse-server setup:
var api = new ParseServer({
databaseURI: 'mongodb://...',
cloud: __dirname + '/cloud/main.js',
appId: '...',
masterKey: '...',
dotNetKey: '...',
clientKey: '...',
fileKey: '...',
serverURL: 'https://<appname>.herokuapp.com/parse',
push: {
ios: [
{
pfx: '....p12',
bundleId: '<bundle-id>',
production: false
},
{
pfx: '....p12',
bundleId: '<bundle-id>',
production: true
}
]
}
});
When i run heroku logs in the terminal i can see the "### TEST" getting printed after start up. But when I save an object of the specified type, nothing is printed in the logs, so it seems that the beforeSave and afterSave isn`t getting called at all.
what's your cloud function looks like? Did you really save a 'SomeClass' object in your cloud function?
The SomeClass object is saved from a client. The code I posted is my entire main.js.
did you have Parse.serverURL="https://fast-badlands-XXXX.herokuapp.com/parse/";
in your main.js?
No, the serverURL is set in index.js, in my ParseServer initialization. Is that wrong?
Are you sure your parse server instance is receiving that object save and processing it?.. for troubleshooting purposes, it's important to know.. are you using an app Id which is also a parse.com app id? Is the parse app also connected to the same database, etc.. I'd run the server with the environment variable VERBOSE=1 and make sure the save was received.
No, I am not sure of that, and don`t quite know how to check it. This is the situation:
- I clicked the Heroku button on the parse-server-example, and set up a Heroku app
- I started the database migration from parse to my new MongoLab base
- I copied keys from parse, into my own Parse Server initialisation (appId, masterKey, fileKey, clientKey)
- I use a client (.NET-client) to make changes to an existing "SomeClass" object (this client connects to the parse database)
- I verify that the change was made in the parse database, and it was synced to the MongoLab database
- I thought that at the point the data was synced to the MongoLab instance, the afterSave() would get called
- I`ve also tried adding records directly to the MongoLab database
The .NET SDK would make a call with the dotNetKey, which if you haven't configured would cause a problem. Here's an easy test... Change the appId for your ParseServer instance and also in your .Net app. I recommend removing any clientKey/javascriptKey/dotNetKey/restAPIKey options.
When going through my .NET client, and not just saving objects directly in the MongoLab database, the cloud functions were called as they should.