I am trying to get a variable from index.js to another file (api.js). I am running it by using
require("/api.js")
This works fine I just want to get some data from index.js to the api.js file. Any help is great!
CodePudding user response:
Export a function from api.js. Call that function from index.js passing the data as arguments.
CodePudding user response:
I used module.export = "Value"
to get the data I wanted. I did this in index.js and required index.js to get the data
const datas = require("./index.js")
const client = datas.Client