I have a small question today. I also found similar topics, which unfortunately did not help me.
I want to load data with Knex and use it further. In the first log console.log(channel['name'])
in the then function I get the name as wanted, but in the last console log console.log(channel);
I only get the message Promise { <pending> }
.
What is the easiest way to use Node.js & Knex.js to get data in this way and use it further?
let channel = knex("channels").where({
twitch_id: twitchID
}).first().then(function (channel) {
if (channel) {
console.log(channel['name'])
return channel;
}
}).catch(function (error) {
console.log(error);
});
console.log(channel);