rosedoucette / Project-6-hot-sauce

0 stars 0 forks source link

Likes/Switch Case #3

Open rosedoucette opened 1 year ago

rosedoucette commented 1 year ago

Hi @AccessiT3ch

I looked at a couple examples of switch cases, both MDN docs and freeCodeCamp, and I think I've got this looking correct, but I fail to believe it's this simple:

const expr = 'Likes'; switch (expr) { case '1': console.log('Sauce liked'); break; case '0': console.log('Sauce unliked'); break; case '-1': console.log('Sauce disliked'); break; }

1) should I use var or const? 2) if I change expr to Likes, what would the value of likes be on the first line? I've seen it done 2 different ways, so I'm a bit confused.

AccessiT3ch commented 1 year ago

@rosedoucette you probably just need to add the default case too :)

rosedoucette commented 1 year ago

For testing the like/dislike...the page never gets past the loading circle after clicking an option. I'm not getting any error and it's logging in the terminal with the proper responses. I'm assuming that counts as good?

AccessiT3ch commented 1 year ago

@rosedoucette what do the docs say to return to the front end upon successfully updating the sauce in the db?

AccessiT3ch commented 1 year ago

@rosedoucette I think as long as you just send some sort of message to the FE, then the FE app will handle the rest :)

AccessiT3ch commented 1 year ago

And remember every controller should only ever return one response per request, no more, no less!

rosedoucette commented 1 year ago

@rosedoucette what do the docs say to return to the front end upon successfully updating the sauce in the db?

The mdn docs? the mongo db docs?

rosedoucette commented 1 year ago

@AccessiT3ch also, I know you mentioned that you can modify the sauce but you can't update the info and the image at the same time. There's no way to update the image so I'm a little confused, but there's also no way to remove the image either. The status I'm getting from the modify function is 404 and the response is simply: Cannot PUT /api/sauces/64e6654f785f979a04317c81

AccessiT3ch commented 1 year ago

@rosedoucette it looks like your modify sauce route is just missing the "/" at the beginning of the route path, which is why it's resulting in a 404 :)

rosedoucette commented 1 year ago

OMG I have spent forever going through every line trying to figure out what the issue was, THANK YOU! It works now, and I was able to fix the delete issue as well. So I believe I have just about everything now

rosedoucette commented 1 year ago

I take it back. It's not throwing errors or anything, but the modified information isn't saving.