I have 2 files QueryExecution.js and app.js; from app.js am calling a function query_result which is in QueryExecution.js. But when I made the call in app.js am getting object.function is not a function.
Kindly apologize for any stupid mistakes :( Thanks in advance for your time and help
I tried to print the object(realtime_chart_new) that I created to call the function. the object is printing the entire function content.
QueryExecution.js
function query_result(connection,sql) {
.......query statements and processing content .....
return CountOrders, TotalAmt;
}
module.exports = query_result;
app.js
var connection = {
.....connection statements .....
};
var realtime_chart_new = require('./QueryExecution.js');
var SalesCountOrders, SalesTotalAmt = realtime_chart_new.query_result(connection,sql);```
#Below is the error statements:
var SalesCountOrders, SalesTotalAmt = realtime_chart_new.query_result(connection,sql);
TypeError: realtime_chart_new.query_result is not a function
realtime_chart_newcontainquery_result, or is it printing the entire function directly? Also, what is exported from the file 'QueryExecution.js' ?realtime_chart_newdirectly prints the entire code that I wrote insidequery_resultrealtime_chart_newis default export and you would need to call it directly likerealtime_chart_new()QueryExecution.js