How do I get reusable blocks via frontend REST API?
We need to be logged in as a user and additionally add the wp_rest
nonce to the block rest endpoint request, either via the _wpnonce
POST/GET parameter or via the X-WP-Nonce
header.
See e.g. the docs for more information on the authentication.
EDIT: As pointed out in comment, to do what questioner is trying to achieve you would need to create a custom endpoint without authentication as the existing block endpoint checks permission of current user.
Related Posts:
- Using Backbone with the WordPress AJAX API
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- Including WordPress in RESTful API
- REST API endpoint for elasticpress autosuggest
- Gutenberg – how to correctly perform ajax request on backend
- AJAX request from Chrome Extension to WordPress Website
- WP REST API route request explain
- Confused on AJAX submit form through page template
- Solve cors problem using rest api or ajax
- Is there a hook to process a backbone restful PUT request inside wordpress?
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- How to add WP API and JS featured image attachment
- how to send Ajax request in wordpress backend
- Identical wp_rest nonce returned from rest_api
- Is there builtin way to use protected AJAX endpoint?
- rest_no_route custom route
- Test WordPress api with postman
- How to load content from many posts on a page, only if needed
- How do I query posts by a sub value with the API?
- merge wp rest api query to get posts per category does not work
- Ways to load admin-ajax faster without initializing all plugins?
- How to make a fetch() POST request to wordpress rest api?
- post values to custom post type which has advanced custom fields
- REST public POST giving 403 forbidden nginx
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- 404 error custom post type rest api
- How to require files in a custom endpoint
- Create a post with REST API and adding a category
- Should I edit a user meta field with PUT, PATCH, or POST and WP::Editable
- How to trigger lost password email using REST API?
- how reduce fetch/XHR response time
- Custom WP rest api endpoint only working on non https?
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- How to submit a button automatically after every scheduled hours?
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- SSL breaks customizer: page isn’t returned from ajax
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Ajax function returns -1
- Problems with creating sortable sections in customizer
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- Filter WP user acf field by ajax
- Ajax Request not coming back to class
- How to make ajax content indexable by search engines?
- Conditional action hooks
- AJAX requests broken due to HTTPS for wp-admin
- query vars in url work but not in ajax call
- Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?
- How to make get_theme_mod work with AJAX in the customizer preview
- How to declare a JS variable in an AJAX call
- is_page() conditional not working inside an AJAX function
- Fatal error: Call to undefined function get_post() with ajax
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- Plugin: AJAX query external API to sync to tables
- admin-ajax.php ” Missing argument 2″ warning
- Update get_pages using ajax on form select change
- splitting the URL using jQuery
- How to make tabulator ajax call in wordpress?
- How would you update a frontend form with AJAX
- Are nonces in WP REST API optional by default?
- Radio buttons live refresh in the customizer
- Admin ajax add tag callback
- Stop auto load wp-admin admin-ajax.php
- wp_enqueue_script() doesn’t work with AJAX
- Dynamically add more fields/remove last field in a form
- Ajax Request for both logged and non logged users
- AJAX call inside plugin class not triggering
- WordPress Heartbeat API cannot parse data
- Ajax function on #publish only saves as draft – how to make it publish?
- AJAX call broken after actualization
- WP_Ajax Hook doesn’t execute this PHP code
- Ajax function not returning any results
- wp_mail doesn’t work when logged in?
- How to continuously send feedback via AJAX responses to my client?
- Need help with Access-Control-Allow-Origin
- Send email via ajax
- wp_ajax handler with multiple class instances
- admin-ajax.php (aborted) error when using jQuery.get
- Storing temporary data for a custom post type
- Load page HTML content through AJAX
- Not getting an ajax readystatechange on my page
- WordPress Select Option Load Custom Fields
- Add ajax to plugin in admin area
- Search live Ajax
- Ajax login fails: script sets cookies, but is_user_logged_in() returns false
- Ajax call on class returns old data
- delete post meta data in array WordPress
- Display post thumbnail after clicking on post id with AJAX
- Error while submitting form using AJAX and php
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Is it a good idea to init ajax functions only while ‘DOING_AJAX’
- register_setting and AJAX?
- ajax response is 0 instead of ‘script’ [duplicate]
- A refreshless WordPress website
- get_template_part() does not render after the ajax request
- $wpdb Ajax not redirecting to main page