Skip to content

Instantly share code, notes, and snippets.

@ismaelc
Last active December 27, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismaelc/7242075 to your computer and use it in GitHub Desktop.
Save ismaelc/7242075 to your computer and use it in GitHub Desktop.
Define the Cloud Code "yodaSpeakFunction" and initialize/call the Cloud Module "yodaSpeak"
// 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