Call function from file in node js?

There is a file with the contents
import {} from ....
import {} from ....
import {} from ....

export const func = [
{
 fname: 'test func',
 func: (contract) => {
console.log('1')
}
},
},
{
 fname: 'test функ2',
 func: (auto) => {
console.log('2')
}
},
}]


Read what for files need the fs module
Pull up, output the data to the console receives the whole file. Tell me how can I pass an argument to call certain function from that file?

for example I give auto and call the function from the 2nd object, give the contract - from the 1st
April 4th 20 at 13:27
1 answer
April 4th 20 at 13:29
It is not clear why to connect the modules you want to use the module "fs".
To connect NodeJS can use
const myScript = reqiure("./index.js");
const config = myScript.getConfig();

and if you did the module export module, you can easily to use the functions that are inside :)

you have written in the example import using
import {} from ....
this syntax out of the box in NodeJS is not supported, you will need to use babel to use such imports.

read https://metanit.com/web/nodejs/2.1.php
I read, perhaps I'm not quite correctly expressed.

file import'ω refers to the angular application. And I need to write a service that will pull the functions from export const func depending on the argument passed. - braden10 commented on April 4th 20 at 13:32

Find more questions by tags Node.js