-3
Hello, I am a student of programming, and during a project I came across a mistake that I cannot solve. I am basically in the creation part of "login" route, whose purpose is to search in the database if an "id" exists or not. I am using INSOMNIA , sending as JSON {"id":"7ae8303f"}, in case the id of a created user.
const connection = require('../database/connection');
module.exports= {
async create(request, response) {
const { id } = request.body;
const ong = await connection('ongs')
.where('id', id)
.select('ong_id')
.first();
if (!ong) {
return response.status(400).json({ error: 'No ONG found with this ID'});
}
return response.json(ong);
}
};
ERROR : (Node:20832) Unhandledpromiserejectionwarning: Error: Undefined Binding(s) Detected when compiling FIRST. Undefined column(s): [id] query: select ong_id
from ongs
Where id
= ? limit ?
At querycompiler_sqlite3.toSQL (C: Users Mathe Documents projects backend node_modules knex lib query Compiler.js:99:13)
at Builder.toSQL (C: Users Mathe Documents projects backend node_modules knex lib query Builder.js:72:44)
AT: Users Mathe Documents projects backend node_modules knex lib Runner.js:31:36
AT: Users Mathe Documents projects backend node_modules knex lib Runner.js:260:24
at async create (C: Users Mathe Documents projects backend src controllers Sessioncontroller.js:7:21)
(Ode:20832) Unhandledpromiserejectionwarning: Unhandled Promise rejection. This error either originated by Throwing Inside of an async Function without a catch block, or by rejecting a Promise which was
not handled with . catch(). (rejection id: 2)
(Ode:20832) [DEP0018] Deprecationwarning: Unhandled Promise rejections are deprecated. In the Future, Promise rejections that are not handled will terminate the Node.js process with a non-zero Exit code.