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
- Kadane’s algorithm explained
- Download File Using JavaScript/jQuery
- Disabling and enabling a html input button
- TypeError: Cannot read property ‘then’ of undefined
- How to read xml file contents in jQuery and display in html elements?
- using lodash .groupBy. how to add your own keys for grouped output?
- Uncaught ReferenceError: google is not defined when trying to use Google Places API without a map
- Why is window.showModalDialog deprecated? What to use instead?
- Should I use JSLint or JSHint JavaScript validation?
- How can I print using JQuery
- Angular: conditional class with *ngClass
- Failed to compile. Module not found: Can’t resolve ‘react-router-dom’
- How to send an email from JavaScript
- MissingSchemaError: Schema hasn’t been registered for model “User”
- How to measure time taken by a function to execute
- var.replace is not a function
- Uncaught TypeError: Cannot read property ‘call’ of undefined at __webpack_require__
- Async/await in componentDidMount to load in correct order
- How to open a URL in a new Tab using JavaScript or jQuery?
- How to sort an object array by date property?
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- How can I check whether a radio button is selected with JavaScript?
- JavaScript button onclick not working
- What counts as CPU Intensive tasks (eg. sorting, searching etc?)
- What is the equivalent of Java’s System.out.println() in Javascript?
- How can I exit from a javascript function? [duplicate]
- Object doesn’t support property or method ‘addEventListener’
- How to fix javascript .toFixed is not a Function error
- Implementing Isomorphic JavaScript (React JS) in WordPress?
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- TinyMCE in a div / textarea on frontend?
- Include Javascript as Plain (No file inclusion)
- Adding wp_ajax to a theme outside functions.php (on specific template page)
- Insert shortcode in post editor from javascript (Visual / HTML)
- WordPress problem with htmlentities
- Provide specific example for block variation
- How to add a custom.js file for a child-theme in a swift way?
- var is undefined in a Gutenberg block
- Custom wp.editor.initialize settings ignored
- Why my javascript code not working for the dashboard of wordpress admin?
- Got a TypeError after update and need to adapt found solution
- How to add classes and events to image in javascript using Gutenberg?
- How do you filter the list of states when country is selected? [closed]
- Accessing theme customizer farbtastic object instances
- How to locate a Javascript? It is there in HTML but not in any file [closed]
- Malware gdjfgjfgj235f [closed]
- CDATA removing new line in script tag in wordpress
- How to run Javascript popup modal in a loop?
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Spans in gutenberg
- Get a default customizeAction text for a section using Customizer JS API
- custom page url slug needs illegal ?id=1 for javascript
- Use one javascript variable into another javascript file
- Escaping inline JS correctly
- Why is my JS not working on initial load?