Skip to content

Instantly share code, notes, and snippets.

@lmccart
Last active August 29, 2015 14:15
Show Gist options
  • Save lmccart/b5e82da456859e0eac0f to your computer and use it in GitHub Desktop.
Save lmccart/b5e82da456859e0eac0f to your computer and use it in GitHub Desktop.
// example calling API twice for two difference sentences
var s = 'The cat is mad.';
$.getJSON(s, params, function(data) {
console.log(data);
});
s = 'I am very old and tired and sad.'
$.getJSON(s, params, function(data) {
console.log(data);
});
// example iterating through array of sentences and calling API for each
var paragraph = 'The cat is wearing a hat...blah blah blah. Some more sentences blah.'
var sentences = paragraph.split('. ');
for (var i=0; i<sentences.length; i++) {
$.getJSON(sentences[i], function(data) {
console.log(data);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment