Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GH Commit Block to fetch data from REST API #9

Open
tgglv opened this issue Feb 16, 2022 · 0 comments · May be fixed by #10
Open

Use GH Commit Block to fetch data from REST API #9

tgglv opened this issue Feb 16, 2022 · 0 comments · May be fixed by #10

Comments

@tgglv
Copy link
Collaborator

tgglv commented Feb 16, 2022

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

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.

As a result we would look like the following:
image

What might be useful

@KokkieH KokkieH linked a pull request Feb 21, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant