Reputation: 387
Hi I am very new to Parse Cloudcode and JS. In Cloudcode we need to put functions inside main.js in order to use them. Is there anyway I can organize them into different files and import within main.js so that I can keep main.js clean and short? If so, how to do it?
Also question regarding to debugging: Is there anything like NSLog (Printing out anything on the console) in Cloud code or break point so that I can easily debug my code on cloudcode?
Thanks
Upvotes: 1
Views: 411
Reputation: 324
To answer your first question: Although file size is irrelevant other than for readability, try creating the complimentary js files in the same "cloud" folder. Then to include the functions use require() at the top of the main.js file
require('cloud/userFunction.js');
As for debugging you can use these three mthods
console.log("The user name is " + user.name + " with an age of " + user.age);
//These two post directly to the error log
error.log("Error here " + error.message);
console.warn("Issue in method set name");
You can find the cloud code log in the Parse user dashboard by visiting the app, selecting "Core" at the top, and selecting "Logs" on the bottom of the left menu.
Upvotes: 1