Check out example codes for "rest api node js with mysql". It will help you in understanding the concepts better.

Code Example 1

const express = require('express'),
  app = express(),
  bodyParser = require('body-parser');
  port = process.env.PORT || 3000;

const mysql = require('mysql');
// connection configurations
const mc = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'mydb'
// connect to database


console.log('API server started on: ' + port);

app.use(bodyParser.urlencoded({ extended: true }));

var routes = require('./app/routes/approutes'); //importing route
routes(app); //register the route

Learn ReactJs, React Native from