Ao enviar o objeto json no Postman, aparece o seguinte erro:
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1",
sqlState: '42000',
index: 0,
sql: 'INSERT INTO Atendimentos SET '
Já testei os dois tipos do Content-Type, tanto application/json quanto application/x-www-form-urlencoded e não resolveu.
E no meu código do models está assim:
const connection = require('../infra/conexao');
class Atendimento {
adicionar(atendimento) {
const sql = 'INSERT INTO Atendimentos SET ?';
connection.query(sql, atendimento, (erro, resultados) => {
if (erro) {
console.log(erro);
} else {
console.log(resultados);
}
})
}
}
module.exports = new Atendimento;
Alguém pode me ajudar, por favor?