Backend Error - Can't call a function in a route
Unanswered
Pulx/Mars posted this in #help-forum
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