# Building JS-Rails-API Project
Hi everyone! this is my fourth project already.
Times really flies. this project is the most challenging project I’ve done so far.
I made very simple typing game app. Typing on a keyboard is one of the most essential skills for students and professionals in today’s world. haha.
For this project, I was required to build an app using a Rails API backend and Javascript as the frontend.
In order to generate random words, I am using words API. API provide words as JSON format so that I can use those words on my app.
I didn’t want to use easy words(short words) in my app. so I’ve used word.length > 9 in the function. so I can have long words that length more than 9 letters.
checkMatch function check if your input is same as the words displayed.
if it is match, it add score++ within time interval.
when game ended, I can save game record(name, score) to the database.
I have used three fetch requests to get the data from API.
first fetch request is read.
with this function, I can load data from the API to frontend. so that my data shows on index page. . since I don’t have seed data. there is nothing to load data initially.
request above is create fetch. when game is done, I need to save score with name to the database. This request will be sent to create action in controller. in the create action I could use data input from either a form that is passed along in the data object. without this fetch request, my score will be disappeared whenever I refresh the page.
the last fetch request was for delete.
with this fetch request, I can remove user and score from the database and also remove as from index page as well.
these fetch requests is directed to a specific URL that is associated with a controller in Rails API. The method inside the request lets the controller know what action to send the request to.
Definitely this project was not easy because I needed to control both JS(front-end) and Rails(Back-end). but this is first step to make app or webpage in real life.
I have learned a lot from this project. and this project made me to think what I need to study more.
thank you