'MYSQL column count doesnt match with value count at row 1 nodejs

I know there are many questions like this but I genuinely don't know whats wrong. I have a table with 4 columns (Id, teacherId, class, attendanceRecord). The Id column is auto incrementing. This is the backend:

app.post("/api/attendanceRecord", async(req, res) => {
    const students = req.body.students
    const className = req.body.className
    const teacherId = req.body.teacherId

    connection.query(
        "INSERT INTO attendance(teacherId, class, attendanceRecord) VALUES(?,?,?)",
        [teacherId, className, students],
        (err, result) => {
            if (result){
                res.send({ message: result })
            } 
            if (err){
                res.send({ message: err })
                console.log(err)
            }
        }
    )
})

This is the front end:


  const updateAbsent = () => {
    Axios.post("http://localhost:1337/api/attendanceRecord", {
      teacherId: teacherId,
      className: className,
      students: students
    }).then((response) => {
    if(response){
      console.log(response)
    } else{
      console.log("error")
    }
  })

  }

attendance table:

CREATE TABLE attendance(
    ID INT auto_increment,
    teacherId INT,
    class varchar(255),
    attendanceRecord VARCHAR(1000),
    PRIMARY KEY(ID)
);

Any help would be appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source