Database connection dies after first call
Answered
DentFuse posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/249812857686851584/5cb75a53c37693005e3819eb30e505f4.webp?size=256)
DentFuseOP
Hello everyone, I'm trying to connect to a MongoDB database via the API routes provided by Next. The first requestr goes though and a connection is made to the server, but all further request get lost because it keeps trying to connect to the database again and again. I can seem to get caching working. Please help. Attached my code.
![Image](https://cdn.discordapp.com/attachments/1205579273671282718/1205579274086781008/image.png?ex=65d8e231&is=65c66d31&hm=bb7527a089141d43b20d053d8438f8341bf3599671d17b8092b3f8af4dedc15e&)