Okay, I figured it out!
First, I created a rest endpoint in PHP.
https://github.com/bbuilds/ih-top-nurses-block/blob/main/inc/rest.php#L11
The rest point has optional parameters using regex and then in the register_rest_route()
callback builds a fetch URL depending on the parameters passed to the WP-REST endpoint.
It then fires to the external API wp_remote_get($fetch_url)
and dumps the data into the REST endpoint.
https://github.com/bbuilds/ih-top-nurses-block/blob/main/src/edit.js#L77
Then in my block edit function, I set up the internal rest API call using apiFetch from "@wordpress/api-fetch"
using a similar buildFetch API.
Related Posts:
- 404 in gutenberg autosave of a Custom Post Type with custom rest_namespace
- Editor API Endpoint or Data Store That Provides a List of Meta Fields for Post Types
- Is it possible to access the wp-admin from one instance while keeping WP_HOME pointing to the balancing url?
- Custom Endpoint API based on attribute gutenberg block
- Custom validation on publish/ update in Block Editor
- Unable to edit server side rendered block
- apiFetch() returns infinite requests
- Block editor – Too many requests for server host
- fetch more than 100 records in block editor API call
- Block editor not loading with rest api custom code
- Allow excerpt for pages in Gutenberg?
- WordPress Gutenberg Embed Blocks Are Not Responsive
- How to query multiple post types inside Gutenberg options panel?
- Implementing Gutenberg RichText onSplit / onReplace
- Gutenberg moving core blocks between categories
- Get post from custom REST endpoint in Gutenberg
- Reset data when the field is cleared
- Is there a hook or filter yet for Gutenberg Block Editor to not auto-add Noreferrer to links with a target?
- How to remove specific panels in the editor (Gutenberg) when editing a block (via right panel)?
- Is it possible to use to create a “switchable” preview of a Carousel Gutenberg block?
- What is the significance of ‘root’ in getEntityRecords?
- Trying to get an api request getting error 404
- How to Disable Gutenberg & Return to the Classic WordPress Editor Without any Plugins
- Gutenberg default value not saved in json
- Gutenberg default initial values for FocalPointPicker
- Pre-set CSS class into custom block/template
- How to check whether Gutenberg editor is installed or not [duplicate]
- How to align a single Gutenberg block button in WP 5.5.3?
- Is it possible to print the output of a Gunteberg block with no classes?
- How can you reset InnerBlock content to base template?
- Gutenberg Multiple InnerBlocks
- How can we mimic the columns block in Gutenberg to instead be a list?
- How to set Gutenberg preferences programmatically with wp.data.dispatch?
- Dynamic Gutenburg block output echoes in WP Dashboard
- Are gutenberg blocks ideally supposed to look the same in both back-end and front-end?
- How to output child block attributes on a parent block
- Is there a better way to to make async API calls using the @wordpress/data module?
- How can I center Gutenberg buttons on mobile?
- Extend the “core/link” Block Format
- Passing settings from Reusable Block to it’s children
- Gutenberg element: How to usw Rangecontrol with two values to imitate a rangeslider?
- Is there any simple way to remove Gutenberg editor H1 H5 H6 and change the label for the rest H2 H3 H4?
- Deprecated for blocks.getSaveElement
- WordPress filter post content with PHP before editing it in Gutenberg
- Pass PHP vars to gutenberg sidebar
- Suggested image dimensions Gutenberg Hook
- How Add New Button to Gutenberg Editing Toolbar
- How to force gutenberg to reload blocks after saving
- How can I programaticly open Gutenberg
- Update a block template and apply those changes to an existing post/page
- Blocks Rest API rest_cannot_delete
- How do you manage the Gutenberg block previews in the admin area?
- Custom block save does not match due to stripped slashes from br tag and added figure tag around images
- How to disable align-wide for specified blocks in Gutenberg
- How do I get the site url from a Block (within the block editor)
- Deprecated function not working in Gutenberg
- Gutenberg Block checkbox check-unckeck does not work
- WordPress npm run build and start only outputs wp-scripts start but does nothing
- Gutenberg get index of gutenberg innerblock
- Gutenberg : how can I get the title of the current block within its ‘edit’ function?
- How to use apiFetch to get author information in Gutenberg properly?
- Gutenberg – Remove add block button
- how can default_content filter tell if content will load in block editor or classic editor?
- Gutenberg programmatically move block to position
- Gutenberg somehow not loading in WP 5
- Gutenberg block – remove setting for core/file
- Gutenberg JavaScript error
- Gutenburg: Remove border of selected block
- Sort Posts by Sticky then by Latest date using the Latest Posts Block
- Unwanted white space next to inputs added within `PluginDocumentSettingPanel` using “
- ToolbarDropdownMenu component missing from @wordpress/scripts package
- Gutenberg Custom Block Not Validating – Ideas?
- Gutenberg dynamic block render_callback gives null for $post
- Editing HTML structure of Gutenberg layout recent post?
- How to add srcdoc attribute to YouTube oEmbed in Gutenberg oEmbed Block
- Pass props / function to InnerBlocks
- Categories in Gutenberg
- Block editor: content resets to the previous state in “Edit as HTML” by clicking somewhere outside of the editing window
- Possible to add the title of a custom gutenberg block to the edit screen?
- Post Format Link using Guttenberg
- How do I hide the UI for specific Gutenberg Blocks?
- Creating a Dynamic InnerBlock that updates depending on state
- Resizing images on page
- When to use removeEditorPanel()
- Error After Installing Gutenberg plugin (caused by attempt to stop WP from stripping out tags)
- Block validation failed – escaped HTML in content save
- Add media dynamically on gutenberg block
- FormTokenField passing objects to value property
- Trying to save an object into post meta with wp.data.dispatch(‘core/editor’).editpost
- Core Block Columns Attributes for Innerblocks Template
- Get Menu Items from REST API (React)
- WordPress – Increase number of posts in “Add Link” dialogue
- How to automatically reload style variant .json?
- Strange behavior of blocks in the editor
- In Full Site Editing, how do I get the templates I created to appear in the site editor when populating a new page?
- Dynamically add table of contents and add anchor based on heading innerHTML
- How to defer block.json scripts?
- Block validation: Block validation failed – Custom WordPress Gutenberg Block Fails In Editor when reloaded
- How can I prevent a user from selecting exactly one of two (not both or none) categories on a post?
- How to add a tooltip for MediaReplaceFlow from @wordpress/block-editor