1

I'm using the XAMPP software as a local DB and trying to get into the get function at the below with no success. In addition, I can not see any console comments as well: Web error Node.js Thank you for your help!!

var express = require('express');
const cors = require('cors');
var app = express();
var corsOptions=
{
 origin: 'http://localhost:3000',
  optionsSuccessStatus: 200,
  allowHeaders: ['sessionId', 'Content-Type'],
  exposedHeaders: ['sessionId'],
  credentials: true,
}
app.use(cors(corsOptions));
var mysql = require('mysql');
var con = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "",
    database: "apptxtproject"
});

app.get("/getnetworks"), (req,res)=>{
    con.query(`SELECT * FROM appadtxt`, function (err, result, fields) {
        if (err) throw err;
        console.log(result)
    })
}
  app.listen(4000, function () {
    console.log('Haydeeeeee!!!');
  })
  • Maybe this question is answered here: [https://stackoverflow.com/questions/31397638/how-to-connect-node-js-to-mysql-and-wamp-xampp-server](https://stackoverflow.com/questions/31397638/how-to-connect-node-js-to-mysql-and-wamp-xampp-server) – Erick ls Jan 01 '20 at 11:09
  • Hi @Erickls , I think it's not the problem here. I think the issue here is that the "app.get" function is not being executed. – Elick Chitrit Jan 01 '20 at 11:23

1 Answers1

0

In your app.get you have a bad syntax error try this:

app.get("/getnetworks", (req, res) => {
        con.query(`SELECT * FROM appadtxt`, function(err, result, fields) {
            if (err) throw err;
            console.log(result);
        });
    });
Erick ls
  • 186
  • 8