I am using VS code to create a react js application. I was able to get the data using this setup. I can see the results on my console log.
const db = mysql.createPool({
host : 'xxx.xxx.xxx.xxx',
user : 'myusername',
password : 'mypassword',
database: 'mydatabase',
connectTimeout : 10000,
port: 3306
})
app.listen(3306,()=>{
let sqlInsert = "SELECT el.examID, el.categoryID, el.SubCategoryID, el.Question,A.A, A.B, A.C, A.D, A.Answer ";
sqlInsert += " FROM ExamList el ";
sqlInsert += " inner join ExamAnswer A on A.ExamID = el.ExamID ";
sqlInsert += " inner join ExamSubCategory es on es.ID = el.SubCategoryID ";
sqlInsert += " where el.CategoryID = 1 and es.ID = 1";
db.query(sqlInsert,(err, result)=>{
console.log(result);
})
})
But when trying to get the data using app.get. My browser just keep on loading. I tried http://xxx.xxx.xxx.xxx:3306/api/get
app.get("/api/get",(req,res)=>{
let sqlInsert = "SELECT el.examID, el.categoryID, el.SubCategoryID, el.Question,A.A, A.B, A.C, A.D, A.Answer ";
sqlInsert += " FROM ExamList el ";
sqlInsert += " inner join ExamAnswer A on A.ExamID = el.ExamID ";
sqlInsert += " inner join ExamSubCategory es on es.ID = el.SubCategoryID ";
sqlInsert += " where el.CategoryID = 1 and es.ID = 1";
db.query(sqlInsert,(err, result)=>{
res.send(result)
})
});
I also tried https://xxx.xxx.xxx.xxx/api/get and this is the error message The connection for this site is not secure xxx.xxx.xxx.xxx sent an invalid response. ERR_SSL_PROTOCOL_ERROR
I am very new in react js and only relying on tutorials right now but I was able to build my application. And now I am facing this issue. I've been trying to solve this for 2 days now. Hope someone can help me with this.