node-firebird icon indicating copy to clipboard operation
node-firebird copied to clipboard

Cant get a data(POSTMAN)

Open LabelMinsk opened this issue 2 years ago • 1 comments

Hi everyone... i`m so sorry. but i need help. When i get data from DB, i can print result on console.log. But when i trying return data i get emty.

If you can help me. What is a problem? Thx a lot...

webstorm64_A3GJ2WYjYc .

LabelMinsk avatar Mar 29 '22 06:03 LabelMinsk

That code is right!

`app.use((req, res) => {

    firebird.attach(OPTIONS, function (err, db) {

            if (err)
                throw err;
            // db = DATABASE
            db.query('SELECT * FROM spr_abon s where s.nom_abon = 35 and s.id_region = 39', function (err, result) {

                db.detach();
                res.setHeader('content-type', 'application/json');
                res.send(JSON.stringify(result))
                res.end()
            });

        }
    )

})`

LabelMinsk avatar Mar 29 '22 11:03 LabelMinsk

Hi @LabelMinsk This issue is resolved. Please close it.

Btw, use: res.json(result) // same res.setHeader(...) & res.send(JSON.stringify(result))

jesusvilla avatar Nov 08 '22 01:11 jesusvilla