Implementing a REST API using JavaScript
So far, we have learned about creating tables, as well as inserting, updating, and deleting data using a relational database and a terminal. However, we do not have access to this terminal from our microcontrollers. To communicate with our database server from the microcontrollers, we will introduce a middleware, called an API server. There are various types of APIs but we will utilize REST.
We will implement a REST API using a server-side version of JavaScript called Node.js. From the website, it is described as an asynchronous, event-driven JavaScript runtime that lets you run JavaScript code outside of a web browser. You can learn more about it at https://nodejs.org/en. Let’s begin by installing the Node.js CLI from the Ubuntu CLI.
Installing Node.js
Follow these steps to install Node.js on your instance of Ubuntu Server:
- Log into the remote server using the following shell command, making sure you replace the IP address...