I think you have to pass in menu_selected
edit: withAPIData( ( props ) => {
return {
menu_selected: `/menus/v1/menus/${ props.attributes.menu }` // custom endpoint
};
} ) ( ( { menu_selected } ) => {
I was able to do a very similar thing like so:
edit: withAPIData( () => {
return {
posts: '/wp/v2/images?per_page=4&_embed'
};
} )( ( { posts, className } ) => {
if ( ! posts.data ) {
return "loading !";
}
if ( posts.data.length === 0 ) {
return "No posts";
}
Related Posts:
- Search for a keyword across post types in a Gutenberg component
- Gutenberg core/file add style support in js/ json
- Use a JSON array with objects with javascript
- Uncaught SyntaxError: Unexpected token u in JSON at position 0
- Unexpected token u in JSON at position 0 (but only sometimes)
- SyntaxError: Unexpected token o in JSON at position 1
- What is the convention in JSON for empty vs. null?
- Nested JSON objects – do I have to use arrays for everything?
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- How to compare arrays in JavaScript?
- jQuery AJAX cross domain
- SyntaxError: Unexpected token o in JSON at position 1
- How to convert JSON object to JavaScript array?
- Uncaught TypeError: data.push is not a function
- React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- How do you put an image file in a json object?
- TypeError: res.json is not a function
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- Convert array to JSON
- JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?
- How to add a button dynamically using jquery
- Using setTimeout on promise chain
- Complex JSON nesting of objects and arrays
- How can JavaScript save to a local file?
- Write / add data in JSON file using Node.js
- What are the differences between JSON and JSONP?
- WP Rest API – How to get featured image
- What are all the query parameters for getEntityRecords?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How to only enqueue block javascript on the frontend when its needed [duplicate]
- Extend core block in Gutenberg
- Gutenberg custom block plugin with custom image sizes
- Get loading state of wp data selector
- Hooking a callback into the code within a Gutenberg block
- conditional layout based on if Innerblocks is not empty
- Gutenberg extend blocks add new class name
- initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg
- Correctly handling WordPress core data retrieval in Gutenberg
- Is there a client side API for handling transients or options?
- Updata Metadata WP Rest API
- Adding a text element in between title and blocks container
- Gutenberg RichText
- Use useSelect/useDispatch instead of withSelect/withDispatch
- How to handle Gutenberg wp.data async errors?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Load script after block is inserted
- How do I access site and block editor state data and use `useSelect()` or `withSelect()` to bind it to my components?
- Block Editor: How to get title and post content within the WordPress admin UI in Javascript?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- Gutenberg add extra attributes to custom format
- Using wp.data.select get actual tags (not id’s) used in post
- event/callback on block update?
- How to remove p / br elements from gutenbergs editor
- 404 Error Contact Form 7 on WordPress
- Base64 & JSON Encode array in PHP, use as HTML data attribute, decode and parse in JavaScript …. with proper Escaping
- Pass data from wordpress to javascript in JSON
- How to disable inline css styles generated by Gutenberg editor?
- Programatically update posts in database from one block to another using transform
- Gutenberg getMedia() in post query doesn’t return all featured images
- How to transform a legacy widget into a block
- Gutenberg select categories
- Listening change event of taxonomy term checkboxes in Gutenberg editor
- What is the correct way to import the blocks-editor?
- Open MediaUpload from external component in Gutenberg
- Gutenberg extend blocks add new class name
- Using apiFetch for retrieving post data in Gutenberg
- Add custom classes for blocks in editor based on custom attributes
- Looping over wordpress meta to create “ ‘s?
- How to load an additional script for a block in the block editor?
- How to include a JSON file on my page?
- Gutenberg consume wp-json data and reflect in frontend the content
- Trigger wp-embed via JavaScript to refresh iframe preview?
- Gutenberg getBlockIndex in save() function
- Widgets and Post/Page edit/new blank, console errors only, no server errors
- Trying to turn the Edit function into a class to be able to use React lifecycle methods
- Conditional save return on Gutenberg Block
- Can I alter the block editor’s paste text behavior?
- Custom Gutenberg-Block esnext pass variables
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- How to read inline-CSS from Gutenberg block?
- Custom Gutenberg block: access dom element via JavaScript
- Custom Block – save.js function not saving attributes
- how to use nimble-API and Display data?
- Including dependencies using @wordpress/dependency-extraction-webpack-plugin
- Uncaught TypeError: r is not a function
- Remove escape characters from JSON string pulled from a database
- WordPress Gutenberg Ajax request
- WP Gutenberg – custom block with two content fields
- How do I make a savable preview like Youtube Gutenberg block?
- iFrame onLoad in custom Gutenberg block
- I would like to retrive JSON value and display it in wordpress page or widget
- Block pattern conflict with custom block
- Table block variation with header section activated
- Filtering Gutenberg Components, not Blocks
- Where to include JS library in gutenberg blocks
- 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
- Is it possible to add javascript to template parts
- How to add a new attribute to core wp block editor without npm?
- How to add more elements to an already existing section in Gutenberg