Connecting ExpressJS to MySQL and creating an API Endpoint.
[ADD] Role Statement
[ADD] Set request CORS in .env
[ADD] Method Operation Created, Read, Update, & Delete
[FIX] Cors Request
npm i mysql-endpoint-express
DB_HOST=localhost
DB_PORT=5000
DB_USER=username
DB_PASSWORD=password
DB_DATABASE=database
PREFIX_ROLE='admin'
ALLOWED_ORIGIN='*'
ALLOWED_METHODS='GET, POST, PUT, DELETE'
ALLOWED_HEADERS='Content-Type, Authorization'
require('mysql-endpoint-express');
node index.js`
- Open in browser:
http://localhost:3000/api
- go to our github repository to see the demo application
Don't forget to give stars Follow Me: FOLLOW