0

Its not taking the next input, it simply not taking the inputs and moving to next line or taking single input and again asking for the same input continously in a infinte loop.

const express = require('express')
const mysql = require('mysql')
const prompt = require('prompt-sync')()
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });

const db = mysql.createConnection({
    host     : '161.97.186.200',
    user     : 'careerassistant',
    password : 'P@$$word@1234',
    database : 'test'
})

db.connect((err)=>{
    if(err){
        return err
    }
    console.log('Conntect to Database Test')
})

app.get('/add',(req, res)=>{
                        
        let id = readline.question('Enter id')
        let roll = readline.question('Enter roll')
        let dept = readline.question('Enter dept')
        let clg = readline.question('Enter clg')
                        
        let query = 'insert into classroom(_id, _roll_no, _department, _college) values(?,?,?,?)'
        db.query(query,[id,roll,dept,clg],(err, result)=>{
            if(err){
                console.log(err)
            }
            console.log(result)
            res.send(result)
        })
    })

app.listen('3000',()=>{
    console.log('Server started on 3000')
})

I'm getting error as

error

I also tried using readline it doesn't work too. readline is also raising same type of error

0 Answers0