DEV Community

Discussion on: Connect to MongoDB Atlas from SvelteKit

Collapse
 
mawoka profile image
Mawoka

I am getting the error that global is not defined. Any idea why?

Collapse
 
kvetoslavnovak profile image
kvetoslavnovak • Edited

I am not sure. When exactly are you getting this error?

Collapse
 
todd_fincannon profile image
Todd Fincannon

I encountered the same problem. It turns out I was doing the mongodb import in a Svelte component, where global is not present. It works fine in a JS endpoint — which is where it would go in a real app.

Thread Thread
 
kvetoslavnovak profile image
kvetoslavnovak • Edited

Sure thing, never connect directly to your database from the client. That would be really dangerous practice.