The issue was I overrode the Backbone.sync method only in Backbone.Model. When Backbone fetches the initial data (GET) it is using the sync method in Backbone.collections.
So I need to override the sync in Backbone.Collections:
app.Collection = Backbone.Collection.extend({
sync: function( method, model, options ){
return Backbone.sync(method, this, jQuery.extend( options, {
beforeSend: function (xhr) {
xhr.setRequestHeader( 'X-WP-NONCE', POST_SUBMITTER.nonce );
},
} ));
},
}) ;
With that the nonce is sent with the GET request as well as POST, PUT and DELETE.
You might be able to override Backbone.sync and thus cover both Model and Collection at once.
Related Posts:
- Rest API invalid nonce with Backbone Client
- Setting/unsetting terms using the Backbone JavaScript client
- How to render WP Rest-API Endpoints in a React.js Theme with Woocommerce
- Check if user can in javascript
- wp-api Backbone JS Client fetch options
- Nonce retrieved from the REST API is invalid and different from nonce generated in wp_localize_script
- Show only images and videos in a wp.media window
- REST API: Backbone and custom endpoint
- Open media frame and select an attachment
- Gutenberg custom block plugin with custom image sizes
- Get loading state of wp data selector
- Switch to the library tab in the media uploader
- What type of template are WP media-modal’s templates?
- WP REST – video and audio players
- Headless WordPress: How to authenticate front end requests?
- Post to WordPress using REST API from external site
- How to handle malformed response from WP REST API?
- Rest API authentication issue when called from fetch request in bundle.js
- Get HTTP response code on non-2xx apiFetch request
- WP REST API Post Status Using JavaScript
- How to retrieve a value from an input field in a media view template
- How to transform a legacy widget into a block
- Authentication with the Rest API when using an External Application
- Get Block Attributes in JSON REST API
- Checks when fetching data from multiple REST API endpoints in Gutenberg
- Is there a media_upload_tabs-similar filter to add tabs to the simple/featured image picker?
- Search for a keyword across post types in a Gutenberg component
- Using apiFetch for retrieving post data in Gutenberg
- Get terms of a taxonomy using useSelect
- Return ‘X-WP-Total’ from headers in response
- Retrieving data about comments and likes
- how to use nimble-API and Display data?
- Why does my array sort order changes when I pass it to JS using WP_REST_Response?
- Rest API and how to deal with it in server side
- URL issue retrieving Custom Post Types using Backbone JS API
- Insert HTML markup to page content from the Media Frame modal
- [Vue warn]: Error in render: “TypeError: Cannot read property ‘wp:featuredmedia’ of undefined – REST API
- Update block once an API request returns with a value
- Get user in rest API endpoint
- How to improve WP-Rest atrocious response time?
- I would like to retrive JSON value and display it in wordpress page or widget
- Connecting a wordpress site to an AngularJS APP
- WordPress REST API response is empty in browser and script, but not in Postman
- WP REST API – “rest_user_cannot_view” ONLY on specific users
- Get Comment Text via REST API
- Embedded data and the _fields parameter in getEntityRecords
- REST API not returning all tags – is there a way to return all tags even ones that are not part of published posts?
- WordPress REST API and Backbone JS
- Get current day using javascript [closed]
- Google AdSense Ad not showing up in WordPress Blog [closed]
- Change color of a specific word generated by script [closed]
- dropdown does not work [closed]
- Google Map JavaScript error after migrating
- Browser is showing Javascript code instead of processing it [closed]
- WordPress Gutenberg: Attribute overwritten by block duplicate
- Anyway to disable the auto excerpt creation?
- Table block variation with header section activated
- Filtering Gutenberg Components, not Blocks
- How to remove js using theme, which was added by plugin in WordPress site?
- WP Rest API feature image breaking react component
- How do I cycle a JS function in WordPress? [closed]
- Where to include JS library in gutenberg blocks
- How to load JavaScript modules with script_loader_tag hook?
- How to delete child block for associated parent block
- Passing object to FormTokenField suggestions
- Registration fields prefilled with URL parameters
- Theme path of WordPress inside javascript file
- Uncaught ReferenceError: tippy is not defined
- Divi Carousel/ Slider – How to slide two sliders with a single button
- Uncaught SyntaxError: missing ) after argument list [duplicate]
- Masonry grid with bootstrap 4
- Why is this script not working?
- Error – Uncaught TypeError: e.dispatchEvent is not a function
- Use add_action to run a script, but only on the post editor page
- How To Include JS Script with WP 2023 Theme
- Update js file on wordpress page after making changes
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?
- How can I show a Slot/Fill in the block editor
- How to securely set dynamic HTML content with JavaScript?
- Is it possible to add javascript to template parts
- Styling parent based on a child element of a child in a WordPress page
- How to add a new attribute to core wp block editor without npm?
- How to Update a variable even if the web page reloads in js
- Astra Mobile Cart Drawer is blank on home page
- How to add more elements to an already existing section in Gutenberg
- How do i get an Inline style in Gutenberg Block show up in front end?
- Can I use the Backbone REST API client outside WordPress?
- WordPress adds and tags into HTML blocks after saving
- javscript that updates div in a single wordpress page
- How do i fix type error
- What filtering is available for backbone.js?
- How to limit what fields are returned through the WP API Backbone JS client
- I have custom html mixed with inline javascript that I want added to my WordPress site, how do I achieve this?
- CCF7 Field numbuer prefilled after Click event
- How to update the input[type=number] quantity field using custom buttons?
- Gutenberg core/file add style support in js/ json
- uploading image to wordpress site with javascript fetch function failed
- Sending GravityForms to custom HTML
- How can I look at/edit what’s being sent to post.php when I hit the publish/update button?