What’s the Right Way to get and save remote data for a Gutenberg block?
The way I’m doing it right now is, I’ve implemented my own route and endpoint for the REST API, so that when the author inputs the URL in the editor, it does a PUT to my endpoint. The backend grabs the remote file from that URL, stores it locally, and returns the local file name. That response to the REST API (the local file name) is then stored in another attribute in the block.
Someone pointed out that this probably isn’t correct, as I probably shouldn’t be retrieving that remote data or saving anything until the post is saved. What’s the Right Way to do this?