I’m writing a new block, where one of the pieces of input is a URL to a remote API. That remote API returns some data (in the first instance, a CSV file), which should be saved locally, and then is accessed by the front-end of the block (i.e., I have to get the name/URL of the local file to some front-end javascript).
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?
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com