0
0
Wordpressframework~5 mins

REST API with JavaScript in Wordpress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a REST API?
A REST API is a way for different programs to talk to each other over the internet using simple commands like GET, POST, PUT, and DELETE. It works like ordering food at a restaurant: you send a request, and you get a response.
Click to reveal answer
beginner
How do you fetch data from a WordPress REST API using JavaScript?
You use the fetch() function with the WordPress REST API URL. For example, fetch('https://example.com/wp-json/wp/v2/posts') gets the list of posts in JSON format.
Click to reveal answer
beginner
What HTTP method do you use to create a new post via the WordPress REST API?
You use the POST method to send new data to the server and create a new post.
Click to reveal answer
intermediate
Why do you need to include authentication when modifying WordPress data via REST API?
Because changing data like creating or deleting posts needs permission. Authentication proves you have the right to make those changes.
Click to reveal answer
beginner
What is the purpose of the 'wp-json' part in the WordPress REST API URL?
The 'wp-json' part tells WordPress to use its REST API system to send or receive data in JSON format.
Click to reveal answer
Which JavaScript function is commonly used to call a REST API?
Afetch()
Balert()
Cconsole.log()
DsetTimeout()
What HTTP method is used to update existing data in a REST API?
AGET
BPOST
CPUT
DDELETE
In WordPress REST API, what does the endpoint '/wp-json/wp/v2/posts' return?
AList of pages
BList of posts
CList of comments
DList of users
Why is authentication important when using REST API to modify WordPress content?
ATo avoid using HTTPS
BTo speed up the request
CTo get data faster
DTo prove permission to change data
Which format does WordPress REST API use to send data?
AJSON
BXML
CCSV
DHTML
Explain how you would use JavaScript to get a list of posts from a WordPress site using the REST API.
Think about sending a request and reading the response.
You got /4 concepts.
    Describe why authentication is necessary when creating or deleting posts via the WordPress REST API.
    Consider site security and permissions.
    You got /4 concepts.