feat/sponsors-backend + frontend connection#39
Conversation
… should be good once its fixed.
| }, []); | ||
|
|
||
| if (!sponsors) { | ||
| if (sponsors.length === 0) { |
There was a problem hiding this comment.
length = 0 isn't preferable (if there's no sponsors then we're stuck in an infinite loading state!)
should use !sponsors like before (and usestate defaults to null like previously)
|
|
||
| useEffect(() => { | ||
| Promise.resolve(sponsorsJsonData as SponsorsData) | ||
| fetch("http://localhost:3000/api/sponsors") |
There was a problem hiding this comment.
You should use axios for this, also consider adding a sponsorsApi.ts file to handle basic boilerplate (acts as a quick way to see/update the routes if the endpoint urls ever change)
RLee64
left a comment
There was a problem hiding this comment.
Lgtm! Just two comments to address before you're able to merge in
| @@ -0,0 +1,294 @@ | |||
| import mongoose from "mongoose"; | |||
There was a problem hiding this comment.
Don't commit this file, once you've initialised the DB then you'll no longer need this. If you want to keep a data base template (for potential reversions), you should instead create a JSON/CSV file and save it to our shared drive. That said, doing this isn't necessary since we'll want to add a bulk input option at some point anyway.
| res.json(sponsor); | ||
| }); | ||
|
|
||
| router.get("/", async (req, res) => { |
There was a problem hiding this comment.
make sure to lean() anything you end up returning
… should be good once its fixed.