Node.js Connector TypeError: res.status is not a function
Hallo
I am learning JS scripting and am making a RESTful API with the MariaDB Node.js Connector and Express.js.
But I am stuck on the above mentioned error it has to do with this line ".then((res) =>" because if I do this " .then(() =>" I get no error.
But I also don't get the "res.insertId" in the console.log. What I get is "User added with ID: undefined".
Thanks in advance.
Dimitris
app.post('/users', (req, res) => { pool.getConnection() .then(conn => { conn.query('INSERT INTO users values(?,?,?,?,?)', [ '', 123, 'testuser' ,'' ,'user']) .then((res) => { res.status(201).send(`User added with ID: ${res.insertId}`) //error on this line "TypeError: res.status is not a function" console.log(`User added with ID: ${res.insertId}`) conn.end() console.log('conn end') }) .catch(err => { console.log(err) res.status(500).send() conn.end() console.log('conn end with error') }) }) })
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.