DEV Community

Discussion on: SWR - An awesome react hooks for data fetching

Collapse
 
thomassalty profile image
Thomas Soos

Hi,

I have zero experience with mongodb and swr and I tried following every step in this article but I kept getting 404 errors, both in the browser and in postman.
You may have done other steps that you forgot to include here?

I even cloned the repo from your github and ran npm install to install the dependencies and ran npm run dev which resulted in 500 errors, both in the browser and in postman. Here are a few screenshots:

http://localhost:3000

http://localhost:3000/api/todos

Have you tried starting from zero and just following the steps in this article?

Also can you please add a little bit of explanation for this line?

let db = client.db("truskin-storage"); // free version
Enter fullscreen mode Exit fullscreen mode
Collapse
 
isnan__h profile image
ishan

I started the demo of SWR from scratch. Currently, the database I used has expired due to inactivity, but you can generate your API key and set a .env file. You can generate it by creating a new cluster in MongoDB Atlas.

let db = client.db("truskin-storage");

The string "truskin-storage" is the DB kind of alias name generated by Mongo during the creation of the database itself.