Skip to content

Instantly share code, notes, and snippets.

@alana314
Last active February 24, 2018 07:21
Show Gist options
  • Save alana314/dadf2c8d91ce5336f0c9c95f84c71d29 to your computer and use it in GitHub Desktop.
Save alana314/dadf2c8d91ce5336f0c9c95f84c71d29 to your computer and use it in GitHub Desktop.
Get latest wired article
//Run in console on a page with jQuery. (Most web pages)
jQuery.getJSON('https://www.wired.com/wp-json/wp/v2/posts/', function(response){console.log(response[0].title, response[0].content);})
//Here's a version that doesn't need jQuery:
xhr = new XMLHttpRequest;
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
response = JSON.parse(xhr.responseText);
console.log(response[0].title, response[0].content);
}
}
xhr.open("GET", 'https://www.wired.com/wp-json/wp/v2/posts/')
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment