So i've been searching around the website for a soultion and came across something that has worked for a user previously and tried to copy how it was done just to test out using a callback function to return a result from a query would work, but I'm having problems. Here's my code
dbfunctions.js
const connection = require('../helpers/connection');
function getUserInfo(userID, dynamicField, callback) {
var query = connection.query("SELECT * FROM subgutter WHERE name = 'random'");
query.on('result', function(row) {
callback(null, "row.dynamicField");
});
};
module.exports = getUserInfo();
g.js
const express = require('express');
const router = express.Router();
const connection = require('../helpers/connection');
const dbfunctions = require('../helpers/dbfunctions.js');
dbfunctions.getUserInfo(8, "test", function(err, result) {
console.log(err || result);
});
this is giving me in dbfunctions.js callback is not a function
via Tony
No comments:
Post a Comment