public
Last active

The Cloud Module Yoda Speak where the Mashape API is called

  • Download Gist
yoda-1.0.0.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 26 27 28 29 30 31 32 33 34
// Cloud Module yoda-1.0.0.js
 
// Set url of Mashape API to call
var url = 'https://yoda.p.mashape.com/yoda';
var key = '';
module.exports = {
 
// Method to initialize module
initialize: function(mashapeKey) {
key = mashapeKey;
return this;
},
 
// 'yodaSpeak' method to make an HTTP request call to Mashape API
// Uses Javascript Promises ('then') to execute success or error callback through 'options'
yodaSpeak: function(params, options) {
return Parse.Cloud.httpRequest({
url: url,
headers: {
'X-Mashape-Authorization': key
},
params: params,
}).then(function(httpResponse) {
if (options && options.success) {
options.success(httpResponse);
}
}, function(httpResponse) {
if (options && options.error) {
options.error(httpResponse);
}
});
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.