Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialQuint Rahaman
7,084 PointsWordPress REST API, GET all posts
Hello,
I am building a Dashboard on the front-end which will contain several Highchart charts. In an earlier version of the WP REST API, one could get all posts from the database in JSON. This is no longer possible. Could someone explain using JavaScript, not PHP, how this could be accomplished?
Thank you!
1 Answer
Jacob Mishkin
23,118 PointsHonestly, This question is too big to answer in the forum, and should be a course here at Treehouse, but to get started, do you have the app postman? if not you will need that. I take it you've been using the REST API a little bit as of now?
What was your process before, that way we can see what you are doing right now and what needs to be changed. Are you authorizing? JWT, OAuth 2?
Quint Rahaman
7,084 PointsQuint Rahaman
7,084 PointsThanks for taking the time to respond, Jacob. After much searching, I found that the jqXHR object contains the number of pages for the specified post type. The following, see below, is what I've done. I have no idea if this is an efficient way of pulling back the post data especially if the database contains millions of posts? With regard to your question about authentication, that's something that I have not been able to get my arms around beyond the basic authentication. Do you know of a good resource to implement OAuth2 for a relative beginner/intermediate person.
By all means, I would appreciate your feedback...