Last active
February 24, 2018 07:21
-
-
Save alana314/dadf2c8d91ce5336f0c9c95f84c71d29 to your computer and use it in GitHub Desktop.
Get latest wired article
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 characters
//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