Skip to content

theredspoon/React_Workshop_by_Kintone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

React Workshop by Kintone - Version 3

Let's POST Data to a Web Database From a React Component

Thank you for attending our Kintone x React workshop!

Outline

Get Started

First, let's download the ahandsel/React_Workshop_by_Kintone Repo and go inside the folder.

cd Downloads

git clone https://github.com/ahandsel/React_Workshop_by_Kintone

cd React_Workshop_by_Kintone
ls

README.md   backend   frontend

Inside there should be two folders (frontend & backend) and a README file.

Open the React_Workshop_by_Kintone folder in VS Code

code .

Let's open a terminal per folder.
Then inside the folders, download the required packages with npm install.

Terminal 1 - Frontend Terminal 2 - Backend
Go inside the folder cd ~/Downloads/React_Workshop_by_Kintone/frontend cd ~/Downloads/React_Workshop_by_Kintone/backend
Install packages npm install npm install
Run the scripts npm start npm start
View Results localhost:3000 localhost:5000/getData
Expected Results React App listing out records from Kintone Web Database App Raw API response in JSON with all the records

⚡ Note: Please ignore the package deprecation warnings ⚡

Overview of the Repo

File Path Purpose Need to Modify?
index.js frontend/src/index.js Nope
index.html frontend/public/index.html Nope
App.js frontend/src/App.js Yes! - Append POST
getRecords.js frontend/src/requests/getRecords.js Nope
ListRecords.js frontend/src/components/ListRecords.js Nope
.env backend/.env Holds your Kintone credentials Yes! - Create
server.js backend/server.js Setup the Express server that makes the Kintone API calls Yes! - Append POST
postRecord.js frontend/src/requests/postRecord.js Pass the POST API request from React to Express server Yes! - Code it
InputForm.js frontend/src/components/InputForm.js Appends the form that is used to create a POST API call Yes! - Code it

Kintone Web Database & Credentials

Built for teamwork, designed by you

🚀 Getting your FREE Kintone Database

① Sign-Up for Developer Program Account (Website) 🌐

  • bit.ly/KDP_signup
    • ⚠ Do NOT use Safari
    • ⚡Accept Cookies First
    • ✅ Use Chrome & Firefox

② THEN Create a Kintone Subdomain (Database) 📂

  • bit.ly/K_DevLic
    • ⚡ Only use lowercase, numbers, & hyphens in your subdomain
    • ⚠ Do not use uppercase nor special characters

Confused? 🤔 → Check out the video below:

Video: Sign up for Kintone Developer Program & Developer License

https://youtu.be/Gzz8SbTuoFg
https://youtu.be/Gzz8SbTuoFg

Create a Kintone Web Database App

Let's create a Kintone App to list off your favorite mangas!

Here are the required fields & their configurations for our workshop:

Field Type Field Name Field Code Note
Text Title title The manga's title
Text Author author The manga's author
Record number Record number recordID Auto-generated ID for each entry

Create_App_Demo.gif Kintone_React_Workshop v2.1

Kintone API Token

To generate an API Token for a Kintone App:

  1. Go to the Kintone App
  2. Go to the Gear icon ⚙️ (top right corner) > Open the App Settings page
  3. Click on the App Settings Tab > Click on API Token settings
  4. Click the Generate button to generate a token
  5. Click the Save button (top left corner) to save the token setting
  6. Finally, click the Update App button (top right corner) to implement the token setting change.

🔐 Securely input your credentials in a .env file

In the backend folder, create a .env file.
Follow the template below and input your Kintone credentials.

SUBDOMAIN = ""
APPID = ""
APITOKEN = ""

Here is an example .env file.

SUBDOMAIN = "devevents"
APPID = "1"
APITOKEN = "dXNlckBleGFLtcGxlmNvbTpzZWNyZXQe9q3IhtcG"

Debugging - Let's Fix Those Problems?

Here is a rundown of problems & solutions that may occur during our workshop

How do I get my Kintone Subdomain?

It might be a bit confusing since you need to sign-up for Developer Program Account (Website) 🌐 BEFORE creating your Kintone Subdomain (Database) 📂.

Check out our Sign up for Kintone Developer Program & Developer License YouTube video:

  • https://youtu.be/Gzz8SbTuoFg

Install Node & npm

The code in the workshop requires Node ≥ 10.16 and npm ≥ 5.6.

Confused? 🤔 → Check out our Install Node.JS on macOS & Windows and Create a Sample React App - YouTube Video!

  • https://youtu.be/4Kw-i_rX3tY

React not updating after updating server.js?

After making changes to server.js, be sure to restart the Express server On the Terminal 2 - backend!

  • Stop the server: ctrl + c
  • Start the server: npm start

Then reload the browser showing the React App: localhost:3000

Error from Terminal 2 - backend?

Do you see an error on .../React_Workshop_by_Kintone/backend/node_modules/node-fetch/lib/index.js:272 like the following?

return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
                           ^
FetchError: invalid json response body at https://r.kintone.com/notfound/subdomain.html reason: Unexpected token < in JSON at position 0
    at /Users/g001494/Downloads/React_Workshop_by_Kintone/backend/node_modules/node-fetch/lib/index.js:272:32
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/g001494/Downloads/React_Workshop_by_Kintone/backend/server.js:43:24 {
  type: 'invalid-json'
}

This error is related to your Kintone credentials.

  1. Verify that you have created a .env file with your Kintone credentials inside the backend folder
  2. Verify the Kintone credentials are correct: Subdomain, App ID, and API Token
  3. Verify that the Kintone App is configured as done in the Create a Kintone Web Database App section
  4. Verify that the Kintone Web Database App is updated after generating the Kintone API Token

No response when starting the Express server?

Make sure you are inside the backend folder when starting the Express server.

cd ~/Downloads/React_Workshop_by_Kintone/backend

npm start

Got a UnhandledPromiseRejectionWarning error?

(node:5379) UnhandledPromiseRejectionWarning: FetchError: request to https://.kintone.com/k/v1/records.json?app= failed, reason: getaddrinfo ENOTFOUND .kintone.com

Got a GAIA_IA02 error?

  • Enter the App's API Token in .env file as APITOKEN = ""
  • Be sure to hit the save button & the Update App button to implement the API Token change.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 74.4%
  • HTML 25.6%