Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am trying to fetch information from phpmyadmin database, but in browser it's showing cannot get/employee and in command prompt there is no error

    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
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS E:\Development\crud-node> node index.js
Express server is running on port number: 8000
DB connection is successful

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

there seems to be spelling mistake in end point. The one you specified in error detail and the one defined in the code are different

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading