Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Created July 30, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasPe/5fc8e43dd888f378234d3a7d84e74ce3 to your computer and use it in GitHub Desktop.
Save ThomasPe/5fc8e43dd888f378234d3a7d84e74ce3 to your computer and use it in GitHub Desktop.
Get WordPress data from REST API
function getData(){
context.log('get data');
var options = {
url: 'https://windowsarea.de/wp-json/wp/v2/posts',
method: 'GET',
json: true
}
request(options, function (error, response, data) {
context.log("request callback");
if (error) {
context.log(error);
}
else {
context.log(data.length);
mynews = data;
}
prepareTemplates();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment