I've got some serverless functions running on firebase functions, and I'm getting some strange issues which I think maybe relating to how I'm using modules in Node.js
I have a file that deals just with anything to do with a user
users.js
const { updateAudioDoc } = require('./audio')
const getUser(id) => {
// get user document
}
const addUserStatistics = {
// some code
updateAudioDoc()
}
module.exports = {
getUser
}
I then have another file which just deals with audio
audio.js
...
const { getUser } = require('./users')
const addAudioToUser = id {
// some code
getUser(id)
}
module.exports = {
addUserToAudio
}
With a structure like this, the users.js
file is requesting the audio.js
file, which in turns requests the users.js
.
I'm receiving some errors like getUser() is not a function
. I'm wondering if this is because of this way I've structured modules?