Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
First, we must add a new REST API connection and set up some basic configuration.
Click the “+” button, in the Data section.
Give your datasource a name - this is how it will appear in Budibase. I called mine “GitHub”.
Set the URL to https://api.github.com
. All requests made through this connector will be prepended with this URL.
Add a new “Default Header” for “Authorization”, with the value “token your-token” (replace “your-token” with your GitHub personal access token. All requests made through this connection will include this header.
Click Save
We will use GitHub issues to represent our todo items. So, we need to create a query that will list GitHub issues.
On your API connector, click “Add Query”
Call your query “List Items”
The “Function” should be GET
For the “Path”, enter /repos/<your_github_username>/<your_repo>/issues
.
Click on “Run Query”. This query should run successfully. The schema should be that of a GitHub issue.
Click “Save Query”
Now that we have created our query, we want to display these items in our app.
Go to the design section.
In the Home screen, delete the default component.
Add new Data provider, setting the “Data” to “List Items” - i.e. our query.
Add a new Repeater, inside the Data provider.
Add a Paragraph element, inside the repeater.
Now, we want the ability to create a new todo item, directly from the todo list. To achieve this, we will:
Create a new form, inside your data provider
Add a text input to the form.
Set the input’s “Field” property to Title. We will use this to create a new item.
Add a button to the form.
Click on “Define Actions”, to set the button actions.
Add an “Execute Query” action, and choose your “Create new item” request.
Assign the item_title
parameter to your text input value.
Add a “Clear Form” action. This will clear the input, after the request has been executed.
Add a “Refresh Data Provider” action, and choose your data provider. This will reload the list, to display your new item.
For every item in our list, we want to display a “Done” button. When clicking on the button, the GitHub issue should be closed and our item should disappear from the list.
Create a new query on your GitHub datasource
Name your query “Mark as Done”
Select the PATCH function
Add a new parameter called “item_number”
Set the path to /repos/<github-username>/<github-repo>/issues/{{ item_number }}
Set the body to { “state”: “closed” }
Save your query
Now, we can use this query in our user interface.
First, we will add a new container inside our repeater. We want to display the button and title alongside each other, so must use a container to achieve this layout.
Drag your title “Paragraph” component inside the container.
Add a button to the container and set the text to “Done”
Now, click on “Define Actions” for the button
Add an “Execute Query” action, choose the “Mark as done” query, and pass in the GitHub issue number as a parameter.
Add a “Refresh Data Provider” action.
Our app is a simple Todo list, and we would like to display the list in the center of the page, without a navigation bar.
Add a new container to the Home screen.
In the component tree, drag your data provider inside the container.
Set the container’s Align Items property to “Center”
Click on your Home screen in the component tree, and change the “Layout” to “Empty Layout”. This will remove the nav bar.
Finally - set your theme to “Darkest”!
Next, we want to add the ability to create a new item from our Budibase app. We want to be able to pass in the item title, to the create query. To do this, we’ll create a query with parameters:
Click on your GitHub datasource
Click “Add Query”
Enter the name “Create new item”
The function is “POST”
Add a parameter called “item_title”
Set the “Path” to /repos/<github_user>/<github-repo>/issues
Set the Body to { “title” : “{{ item_title }}” }
. This will pass our item_title
parameter into the “title” field, in the JSON body.
Test your query to make sure that an issue is created.
This guide will show you how to build a todo app, using GitHub issues for storage.
This guide will show you how to build a CRUD application, with the Budibase REST API connector. For this example, we will build a Todo list, using GitHub Issues to store our items.
If you want to follow along, you will need to:
Create a GitHub repository.
Create a GitHub access token with the repo > public_repo
scope checked.
Add a few issues to your repository, so that we have some data to test with.