Last active
December 27, 2015 00:59
-
-
Save ismaelc/7242075 to your computer and use it in GitHub Desktop.
Define the Cloud Code "yodaSpeakFunction" and initialize/call the Cloud Module "yodaSpeak"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cloud Code 'yodaSpeakFunction' | |
// Import Cloud Module from /cloud folder | |
// Initialize Cloud Code with your Mashape key (http://mashape.com/keys) | |
var yodaClient = require('cloud/yoda-1.0.0.js'); | |
yodaClient.initialize('<Enter your Mashape key here>'); | |
Parse.Cloud.define("yodaSpeakFunction", function(request, response) { | |
// Call 'yodaSpeak' Cloud Module passing in 'sentence' parameter | |
// Please refer to https://www.mashape.com/ismaelc/yoda-speak for parameter details | |
yodaClient.yodaSpeak({ | |
sentence: request.params.sentence | |
}, | |
{ | |
success: function(httpResponse) { | |
console.log(httpResponse); | |
response.success(httpResponse.text); | |
}, | |
error: function(httpResponse) { | |
console.error(httpResponse); | |
response.error("Uh oh, something went wrong"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment