Skip to content

Instantly share code, notes, and snippets.

@levlaz
Created August 16, 2015 04:15
Show Gist options
  • Save levlaz/b9ec99547fa3f981f97c to your computer and use it in GitHub Desktop.
Save levlaz/b9ec99547fa3f981f97c to your computer and use it in GitHub Desktop.
Simple JS API using JQuery
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<script src="api.js"></script>
</body>
</html>
photos = $.getJSON('http://wb.bitmonkeys.io/api/get_photos/1', function(data) {
console.log(data); //"Object { Json content }"
var jsonString = JSON.stringify(data); //"{ Json content }", the "Object" literal is removed.
var parsed = JSON.parse(jsonString); //Parse should work now.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment