Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const cors = require('cors');
- const mysql = require('mysql');
- const app = express();
- const SELECT_ALL_QUERY = 'SELECT * FROM project.react_test';
- const connection = mysql.createConnection({
- host:'localhost',
- user:'avd',
- password:'password',
- database:'project',
- insecureAuth : true
- });
- const pool = mysql.createPool({
- host : 'localhost',
- user : 'avd',
- password : 'password',
- authentication_string : 'root',
- insecureAuth : true
- });
- //var pool = mysql.createPool(connection);
- connection.connect(err => {
- if(err) {
- return err;
- }
- })
- console.log(connection);
- app.use(cors());
- app.get('/', (req,res) => {
- res.send('hello from product server')
- });
- app.get('/hola', (req,res) => {
- res.send('hola')
- });
- app.get('/hotels_info', (req,res) => {
- connection.query(SELECT_ALL_QUERY, (err, results) => {
- if(err){
- return res.send(err)
- } else {
- return res.json({
- data: results
- })
- }
- });
- });
- app.listen(4000, () => {
- console.log('Product server listining port 4000');
- });
Add Comment
Please, Sign In to add comment