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
- Split string into array
- convert Hsl to rgb and hex
- What does jQuery.fn mean?
- “Uncaught TypeError: Cannot read property ‘style’ of null at.. “
- Difference between document.referrer and window.parent.location.href
- JavaScript replace/regex
- how to render a react component using ReactDOM Render
- Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters
- OnChange event using React JS for drop down
- how to get the last character of a string?
- Set timeout for ajax (jQuery)
- Escaping Discord subset of markdown
- ESLint Parsing error: Unexpected token
- Angular ForEach in Angular4/Typescript?
- How to handle ETIMEDOUT error?
- bootstrap-datetimepicker for bootstrap 4
- Proper way to wait for one function to finish before continuing?
- XMLHttpRequest module not defined/found
- Bootstrap 4 Dropdown Menu not working?
- document.getElementsByClassName().innerHTML always returns “undefined”
- Bower: ENOGIT Git is not installed or not in the PATH
- Converting an object to a string
- SyntaxError: expected expression, got ‘<'
- Attaching ‘onclick’ event to D3 chart background
- declaration or statement expected javascript/typescript
- The preferred way of creating a new element with jQuery
- How to pass parameters using ui-sref in ui-router to controller
- JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?
- HTML/Javascript change div content
- How do you remove all the options of a select box and then add one option and select it with jQuery?
- Add and remove multiple classes in jQuery
- How To Save Canvas As An Image With canvas.toDataURL()?
- How do I download a file with Angular2 or greater
- What are alternatives to document.write?
- What are differences between SystemJS and Webpack?
- How to find if div with specific id exists in jQuery?
- TypeError: $ is not a function WordPress
- How to echo JS right after enqueued script to put it into noConflict mode?
- How to add JavaScript code on WordPress properly?
- Disable unneeded scripts in a wordpress installation
- Gutenberg getMedia() in post query doesn’t return all featured images
- Can I change an external script’s HTML?
- Adding and removing hidden buttons from WordPress Customizer Tinymce widget editor using javascript API
- Cannot use characters ” in jQuery script in WordPress
- How to install cool javascript feature in WordPress?
- Custom Gutenberg block: access dom element via JavaScript
- Normal for scripts to be loaded after body tag?
- Query String Filtering API
- JS inside modal doesn’t work
- How to Get Post Meta in .Js File [duplicate]
- Immediate (e.g. without DOMContentLoaded) JS not working
- Script not working in post content
- How could I add load more posts to my theme? [closed]
- Javascript button to call custom fields data
- Javascript 2 elements dependent onclick .toggle [closed]