0

I'm trying to make an API using nodeJS, express and Sqlite and Insomnia for requests. I created the tables and everything worked out, it gives no error, but when I do the POST request by Insomnia, the console returns the error TypeError: Cannot read properties of undefined (reading 'name').

my code for database:

import { openDb } from "../configDB.js";

export async function createTable(){ openDb().then(db=>{ db.exec('CREATE TABLE IF NOT EXISTS Pessoas(id INTEGER PRIMARY KEY, nome TEXT, idade INTEGER)') }) }

export async function insertPessoas(pessoas){ openDb().then(db=>{ db.run('INSERT INTO Pessoas (nome, idade) VALUES (?, ?)', [pessoas.nome, pessoas.idade]) })

}

I've redone my code many times thinking it's some syntax error, but I can't find the error.

enter image description here

H3AR7B3A7
  • 4,366
  • 2
  • 14
  • 37

0 Answers0