Home>

Need your help. I try to create a small application using REACT + Node + MySQL. There are problems with collecting data from the database. When I prescribe Localhost: 4000. I have a message Go to /Supercars to See Cars . But when I prescribe Localhost: 4000 /Supercars I have a mistake in the form

{
"Code": "protocol_enqueue_after_fatal_error",
"Fatal": false
}

My database is called Cars, Table -Supercars. What's my mistake? Here is my code. thanks a lot

const express= require ('express');
Const Cors= Require ('Cors');
const mysql= require ('MySQL');
Const App= Express ();
const select_all_Sars_Query= 'Select * from Supercars';
Const Connection= MySQL.CreateConnection ({
Host: 'Localhost',
User: 'root',
Password: 'QWERTY2020',
Database: 'Cars'
});
Connection.Connect (ERR= >
 {
IF (ERR) {
    Return ERR;
}
});
App.USE (Cors ());
App.Get ('/', (Req, Res)= >
 {
Res.send ('Go to /Supercars to See Cars');
});
App.Get ('/Supercars', (Req, Res)= >
 {
Connection.Query (Select_all_Sars_Query, (Err, Results)= >
 {
    IF (ERR) {
        Return Res.send (ERR)
    } ELSE {
        Return Res.json ({
            Data: Results.
        })
    }
})
});
app.listen (4000, ()= >
 {
Console.log (`Cars Server Is Listening On Port 4000`);
});

MySQL itself is running, can you make a request from the console or IDE? Show the changed code, only the existing code do not delete, plz

nörbörnën2021-09-17 01:57:11

@ Nörbörnën, thank you very much, but did not help ((

Ronald2021-09-17 01:57:11

Big So: 26 questions of them 6 with accepted answers

nörbörnën2021-09-17 01:57:11

The first link from Google leads to an explanation of errors and recommendations for correcting github.com/mysqljs/mysql/issuesues/900#issuecoment-53883160

nörbörnën2021-09-17 01:57:11