How to Integrate React Redux + Nodejs/Express RestAPIs + Sequelize ORM – MySQL CRUD example
Tags: mysql, react, redux, sequelize
Published: 2021-05-21 09:26:48

https://grokonez.com/frontend/react/how-to-integrate-react-redux-nodejs-express-restapis-sequelize-orm-mysql-crud-example

How to Integrate React Redux + Nodejs/Express RestAPIs + Sequelize ORM – MySQL CRUD example

In this tutorial, we will build React Redux Http Client & Nodejs/Express RestAPIs Server example that uses Sequelize ORM to interact with MySQL database and React as a front-end technology to make request and receive response.

Related posts:
– <a href="https://grokonez.com/node-js/sequelize-orm-build-crud-restapis-with-nodejs-express-sequelize-mysql">Sequelize ORM – Build CRUD RestAPIs with NodeJs/Express, Sequelize, MySQL</a>
- <a href="https://grokonez.com/frontend/how-to-connect-react-with-redux-react-redux-example">How to connect React with Redux – react-redux example</a>

<!--more-->
<h2>Technologies</h2>
– Webpack 4.4.1
– React 16.3.0
– Redux 3.7.2
– React Redux 5.0.7
– axios 0.18.0

– Node.js/Express
– Sequelize

– MySQL 5.7.16
<h2>Overview</h2>
<img src="https://grokonez.com/wp-content/uploads/2018/12/react-redux-http-client-nodejs-restapi-express-sequelize-mysql-overview-1.png" alt="react-redux-http-client-nodejs-restapi-express-sequelize-mysql---overview-1" width="395" height="611" class="alignnone size-full wp-image-16349" />
<h3>1. Nodejs/Express Server</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/12/react-redux-http-client-nodejs-restapi-express-sequelize-mysql-backend-architecture.png" alt="react-redux-http-client-nodejs-restapi-express-sequelize-mysql---backend-architecture" width="701" height="325" class="alignnone size-full wp-image-16350" />
<h3>2. React Redux Client</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/12/react-redux-http-client-nodejs-restapi-express-sequelize-mysql-react-redux-client.png" alt="react-redux-http-client-nodejs-restapi-express-sequelize-mysql---react-redux-client" width="695" height="408" class="alignnone size-full wp-image-16351" />

For more details about:
– Redux: <a href="https://grokonez.com/frontend/introduction-to-redux-a-simple-practical-redux-example">A simple practical Redux example</a>
– Middleware: <a href="https://grokonez.com/frontend/react/react-redux-firebase-crud-operations-example#Redux_Thunk">Middleware with Redux Thunk</a>
– Connecting React with Redux: <a href="https://grokonez.com/frontend/how-to-connect-react-with-redux-react-redux-example">How to connect React with Redux – react-redux example</a>
<h2>Practice</h2>
<h3>1. Node.js Backend</h3>
- Project structure:

<img src="https://grokonez.com/wp-content/uploads/2018/12/react-redux-http-client-nodejs-restapi-express-sequelize-mysql-nodejs-project-structure.png" alt="react-redux-http-client-nodejs-restapi-express-sequelize-mysql---nodejs-project-structure" width="209" height="340" class="alignnone size-full wp-image-16352" />
<h4>Setting up Nodejs/Express project</h4>
Init <code>package.json</code> by cmd:

<code>npm init</code>

Install <code>express</code>, <code>mysql</code>, <code>sequelize</code> & <code>cors</code>:

<code>$npm install express cors sequelize mysql2 --save</code>

-> now <code>package.json</code> file:

<pre><code class="language-json">
{
  "name": "nodejs-react-restapi",
  "version": "1.0.0",
  "description": "Nodejs React RestAPIs",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "Nodejs",
    "React",
    "RestAPI",
    "Redux",
    "MySQL"
  ],
  "author": "grokonez.com",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.16.4",
    "mysql2": "^1.6.4",
    "sequelize": "^4.42.0"
  }
}
</code></pre>
<h4>Setting up Sequelize MySQL connection</h4>
– Create <code>./app/config/env.js</code> file:

More at:

https://grokonez.com/frontend/react/how-to-integrate-react-redux-nodejs-express-restapis-sequelize-orm-mysql-crud-example

How to Integrate React Redux + Nodejs/Express RestAPIs + Sequelize ORM – MySQL CRUD example