Revision: 65528
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 14, 2013 02:34 by chrisaiv
Initial Code
/**** **** **** **** **** **** **** ****
Two examples of how to Run Parse.Cloud
code with Express
**** **** **** **** **** **** **** ****/
/*
Example: Cloud Function Call
You Can seperate the Parse specific logic from your app
by using CloudFunctions. It keeps seperation nice and tidy.
*/
function runParseCode(formData, callback){
Parse.Cloud.run('hello', formData, {
success: function(results) {
callback(true)
},
error: function(results, error) {
callback(false, error)
}
});
}
function example1(){
runParseCode(formData, function(boolean, error){
if(boolean) res.render('thankyou')
else res.send({"message": "error", "error": error)
});
}
//example1()
/*
Example: Custom Webhook
Since all of this is in the cloud,
ExpressJS has full access to Parse
*/
function runWebHook(formData, callback){
var TestObject = Parse.Object.extend("TestObject");
var testObject = new TestObject();
testObject.save( formData, {
success: function(results) {
callback(true)
},
error: function(results, error) {
callback(false)
}
});
}
function example2(){
var data = {
"fname":"chris",
"lname":"aiv",
"username":"chrisaiv0.29115835297852755",
"password":"password",
"email":"[email protected]",
"phone":"555-555-5555"
}
runWebHook(data, function(boolean){
if(boolean) res.render('thankyou');
else res.send({"message": "error", "error": error)
})
}
//example2()
Initial URL
https://www.parse.com/docs/cloud_code_guide
Initial Description
Parse Cloud Code allows you to build an ExpressJS app that connects with Parse's specialized cloud functions + infrastructure. These two examples simply show how you can access Parse's methods: through webhooks or cloud calls.
Initial Title
NodeJS: Parse Cloud Example
Initial Tags
Initial Language
JavaScript