**How can i export inside function variables and import from another module this data **
//data.js function abc(){ let str = "Turag" function d(a){ let v = a.toUpperCase() return v } const bcd = d(str) return bcd } module.exports.captial = abc //index.js const getData = require('./data.js) "user": getData.v clg(user)
Simply call the exported function, with name you exported like capital not v.
//data.js function abc(){ let str = "Turag" function d(a){ let v = a.toUpperCase() return v } const bcd = d(str) return bcd } module.exports.captial = abc //index.js const getData = require('./data.js) "user": getData.capital(); clg(user)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.