Hello neil,
I've been working with your project and while trying to delete an item from the table the output and the http request is below;
DELETE /delete/undefined HTTP/1.1
but when I intercept the request and change the undefined to a valid ID, it works and deletes fine. So the problem most likely is with passing the Id to the function. The function is below;
(in my database id = chareket_id)
async deleteRowById(id) {
try {
id = parseInt(id, 10);
const response = await new Promise((resolve, reject) => {
const query = "DELETE FROM cari_hareket WHERE chareket_id = ?";
connection.query(query, [id], (err, result) => {
if (err) reject(new Error(err.message));
resolve(result.affectedRows);
})
});
return response === 1 ? true : false;
} catch (error) {
console.log(error);
return false;
}
}
P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mysql\lib\protocol\Parser.js:
437 is running
throw err; // Rethrow non-MySQL errors
TypeError: Cannot read property 'affectedRows' of undefined cd ExpressMyScd server
at Query.<anonymous> (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\dbService.js:74:
36)ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server>nodemon app
at Query.<anonymous> (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mys
ql\lib\Connection.js:526:10)
at Query._callback (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mysql
\lib\Connection.js:488:16)ons: js,mjs,json
at Query.Sequence.end (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\my
sql\lib\protocol\sequences\Sequence.js:83:24)
at Query.ErrorPacket (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mys
ql\lib\protocol\sequences\Query.js:92:8)
at Protocol._parsePacket (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules
\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\m
ysql\lib\protocol\Parser.js:433:10)
at Parser.write (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mysql\li
b\protocol\Parser.js:43:10)
at Protocol.write (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\mysql\
lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (P:\ProgrammingProjects\WebDevelopment\OnGoingProjects\m_f_k\Exps-new\ExpressMySQL\server\node_modules\my
sql\lib\Connection.js:88:28)
[nodemon] app crashed - waiting for file changes before starting...
Hello neil,
I've been working with your project and while trying to delete an item from the table the output and the http request is below;
DELETE /delete/undefined HTTP/1.1but when I intercept the request and change the undefined to a valid ID, it works and deletes fine. So the problem most likely is with passing the Id to the function. The function is below;
(in my database id = chareket_id)