Created
May 11, 2014 20:08
-
-
Save ngsmrk/d34e56b5d60f61bb9ad3 to your computer and use it in GitHub Desktop.
Revisions
-
ngsmrk created this gist
May 11, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ function fetch_random_word() { var req = new XMLHttpRequest(); req.open('GET', 'http://thesaurus-rex.herokuapp.com/random_word/', true); req.onload = function (e) { var status = req.status; var readyState = req.readyState; console.log("Status: " + status + ", state: " + readyState); if (req.readyState == 4 && req.status == 200) { responseText = req.responseText; console.log(responseText); var response = JSON.parse(req.responseText); var theWord = response.word; console.log(theWord); Pebble.sendAppMessage({"word": theWord}); } else { console.log("Error"); Pebble.sendAppMessage({"word": "Not Found"}); } }; req.send(null); }