You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now when you're quite comfortable with the codebase we have, let's try a bit different approach. Instead of doing step-by-step instruction, let's try the way how developers do it. I mean, let's try a format where there is a description including pieces of information rather than exact steps.
Description
We need to make our GH Commit Block be able to fetch data from our REST API.
To achieve that we will use a field for saving a commit hash there.
When a commit hash is pasted to the text field, we need to fetch data from REST API to save commit-related data to the block's attributes.
Let's see how GB works with client-rendered blocks. We need to replace our render callback with a save function in JS instead.
Caveat, you will fetch data in the edit and create an HTML markup in save according to attributes (updated during "edit"), so we just save the resultant block to the DB.
Proposal
Now when you're quite comfortable with the codebase we have, let's try a bit different approach. Instead of doing step-by-step instruction, let's try the way how developers do it. I mean, let's try a format where there is a description including pieces of information rather than exact steps.
Description
We need to make our GH Commit Block be able to fetch data from our REST API.
To achieve that we will use a field for saving a commit hash there.
![Screen Shot 2022-02-16 at 09 10 41](https://user-images.githubusercontent.com/15897544/154208335-a477828e-f87f-4034-bc66-510b01829e7f.png)
When a commit hash is pasted to the text field, we need to fetch data from REST API to save commit-related data to the block's attributes.
Let's see how GB works with client-rendered blocks. We need to replace our render callback with a
save
function in JS instead.Caveat, you will fetch data in the
edit
and create an HTML markup insave
according to attributes (updated during "edit"), so we just save the resultant block to the DB.As a result we would look like the following:
![image](https://user-images.githubusercontent.com/15897544/154209406-da03fdfd-c5bb-4be7-b41e-22ea705ef946.png)
What might be useful
The text was updated successfully, but these errors were encountered: