我试图从phpmyadmin数据库中获取信息,但在浏览器中显示无法获取/雇员,并且在命令提示符中没有错误

fcy6dtqo  于 2022-11-09  发布在  PHP
关注(0)|答案(1)|浏览(65)
const { json } = require('express/lib/response');
    const mysql=require ('mysql');
const express=require('express');
var app=express();
const bodyparser=require('body-parser');
app.use(bodyparser.json());

var mysqlConnection=mysql.createConnection({
    host:'localhost',
    user: 'root',
    password:'',
    database: 'employee_db'
});
mysqlConnection.connect((err)=>{
    if(!err)
    {
        console.log("DB connection is successfull");
    }
    else{
        console.log("DB connection failed "+JSON.stringify(err,undefined,2));
    }
});
app.listen(8000,()=>console.log('Express server is running on port number: 8000'));
app.get('/employess',(res,req)=>{
    mysqlConnection.query('SELECT * FROM EMPLOYEE',(err,rows,fields)=>{
        if(!err)
        {
            console.log(rows);
        }
        else{
            console.log(err);
        }
    })
});

Windows PowerShell版权所有(C)Microsoft Corporation。保留所有权利。
尝试新的跨平台PowerShell https://aka.ms/pscore6
PS E:\Development\crud-node〉node index.js Express服务器正在端口号上运行:8000 DB连接成功

ql3eal8s

ql3eal8s1#

端点中似乎存在拼写错误。您在错误详细信息中指定的端点与代码中定义的端点不同

相关问题