'error <function name> is not a function when importing javascript functions from another file
Im trying to setup an express api for my application and using functions i've already defined in another js file for my api calls.
When I try running this post request i get the error
date is not a function name
I figured there's something wrong with the way im importing my functions and using them
this is how I did the import and used the function
const {captures,date} =require ("..\\..\\captures.js");
module.exports={
visualtest:function(req,res){
captures("C:\\Users\\rami.benromdhane\\Desktop\\dh_automation_test_suites\\json\\report1.json","ref","..\\static\\captures",date(req.body.report1));
captures(req.body.report2,test,"..\\static\\captures",date(req.body.report2));
}
}
this is how my functions or defined in captures.js
function captures(reportjson,testorref,resultpath,date){...}
function date(report){...}
I tried using import from instead of require but then i get the error can t use import statement outside of module
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
