0

I have read several posts regarding this error but I can't seem to diagnose mine. I am getting a cyclic dependency detected with MongoDB when I use curl to send a JSON file POST request:

{"statusCode":500,"error":"Internal Server Error","message":"cyclic dependency detected"}% 

with no other error message.

My post route is as such:

    fastify.post('/newFile', function (req, reply) {
        const movies = this.mongo.db.collection('Movies')
        
        movies.insertOne({ req }, (err, user) => {
            if (err) {
            reply.send(err)
            return
            }
            reply.send(user)
        })
    })

I don't see any immediate cyclical call here...?

Victor M
  • 603
  • 4
  • 22
  • The error message mentions dependency, what did you `require` and what did that file `require` in turn? – Joe Nov 20 '21 at 07:00
  • You can't insert the fastify request object into mongodb. The cycle is there. You must create a new object using the request data. – Manuel Spigolon Nov 20 '21 at 08:37

0 Answers0