Node JS GET API with MySQL

 config.js


const mysql=require('mysql')
const con=mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'',
    database:'test'
});

con.connect((err)=>{
    if(err){
        console.warn("error in connection");
    }

})

module.exports=con;


index.js

const express=require('express');
const con=require('./config12')
const app=express();
app.get("/", (req, resp)=>{
    con.query("select * from user", (err, result)=>{
        if(err){
            resp.send("error")
        }else{
            resp.send(result)
        }
    })
});

app.listen(5000)





Comments

Popular posts from this blog

Send Data Child to Parent Component - React Js

Hide , Show and Toggle in ReactJs

Importance Of Web Content In SEO.