How to import a dynamic object in nodejs

Viewed 12

First, sorry for my bad English. I have one problem with my code. I have a dynamic object in one javacript file (the values in keys are changing per second). I want to use this object to the other file and so I'm using export and require. soure.js

module.exports = {name: name, age: age}

Note that name and age are changing per second randomly

target.js

let person = require('./soure.js')
console.log(person)

It will return an emty object like {}, not like from what I've expected. So my question is: How can I use the source's object in target file?

Thank all

0 Answers
Related