public
Last active

Define the Cloud Code "yodaSpeakFunction" and initialize/call the Cloud Module "yodaSpeak"

  • Download Gist
main.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// 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");
}
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.