Backend Error - Can't call a function in a route
Unanswered
Pulx/Mars posted this in #help-forum
![Avatar](https://cdn.discordapp.com/avatars/1060672342264643604/62c6d97d50995750cdca9fed092923ef.webp?size=256)
Pulx/MarsOP
I got a new ERROR! So I fixed the problem with bun and MongoDB but there is a new problem! When I export the function that ping the database to see if it's alive it's giving me an error and I can't figure out how to fix it. Every time when I call the function that verify if the db is alive, I got the error above. It think it might be a nextjs limitation or something like that. Any idea how to fix that?
but when I run bun path/to/ping.ts it's perfectly working
Also some mentions: I use nextjs v13, bun V1.0.6 if that helps
export default async () => {
try {
await client.connect();
await client.db(`dbname`).command({ ping: 1 });
console.log(
"Pinged your deployment. You successfully connected to MongoDB!"
);
} finally {
await client.close();
}
};
try {
const ping = (await import("./db/ping")).default;
await ping();
} catch (error) {
console.log("Error. Refused to connect!");
}
but when I run bun path/to/ping.ts it's perfectly working
Also some mentions: I use nextjs v13, bun V1.0.6 if that helps
![Image](https://cdn.discordapp.com/attachments/1162836541731786852/1162836541903736882/7ae346f9-0dfb-49c7-8d92-410dbccff0d7.png?ex=653d62ec&is=652aedec&hm=cae6075b690a4bd6a60818e88eb8475e765105fae57f7c51d0ced6c6ffb76a9d&)