API Assistance
-
I’m just learning about the WordPress API and I found this code that works for what I’m looking to do. I need to pull all of the portfolio posts to display the excerpts. Problem is that this doesn’t load all of the posts, There are over 100 and I’m getting about 10. I’m not getting any errors in the console so I really don’t know where to start troubleshooting.
function getExcerpt() { var ourRequest = new XMLHttpRequest(); ourRequest.open('GET', 'https://equipourkids.org/wp-json/wp/v2/portfolio'); ourRequest.onload = function () { if (ourRequest.status >= 200 && ourRequest.status < 400) { var data = JSON.parse(ourRequest.responseText); for (i=0; i < data.length; i++) { console.log(data[i].excerpt) } } else { console.log("We connected to the server, but it returned an error."); } }; ourRequest.onerror = function () { console.log("Connection error"); }; ourRequest.send(); } getExcerpt()
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘API Assistance’ is closed to new replies.