Data Received from frontend is not getting updated in database

26 Views Asked by At
//React Js (frontend) Code

function onclickcancel(){
        setdate('0000-00-00')
        settime('00:00:00')
        settopic('Cancelled')

        axios.put('http://localhost:8081/cancel',{email,date,time,topic})
        .then(res=>{
            console.log("Interview Cancelled")
            seterr("Interview Cancelled")
        })
        .catch(error=> console.log(error))
    }



// Node JS (backend) code 

//Interview Cancel

app.put('/cancel',async(req,res)=>{
    const {email,date,time,topic} = req.body
    
    const sql = "update users SET `Date` = ?, `Time` = ?, `Topic` = ? where Email = ?"

    db.query(sql,[date,time,topic,email],(error,data)=>{
        if (error){
            return res.json(error)
        }
        return res.json(data)
    })
})

Here, I am Sending date =('0000-00-00') time=('00:00:00')topic = ('Cancelled') to backend but this data is not getting stored in my database

date =('0000-00-00') time=('00:00:00')topic = ('Cancelled') this data should update in db when i click cancel

affectedRows: 1
changedRows: 0
fieldCount: 0
insertId: 0
message: "(Rows matched: 1 Changed: 0  Warnings: 0"
protocol41: true
serverStatus: 34
warningCount: 0
0

There are 0 best solutions below