URL shortener project, help with POST request that is not working


#1

Hi everyone! Hope you’re having a great Saturday :slight_smile:

I’m working through the freeCodeCamp API projects and I managed to write this URL shortener with the help of a bunch of tutorials, but I cannot get it to work. I’m obviously doing something horribly wrong :joy: but I’m still trying to wrap my head around GET and POST requests. Could someone please help me out?
This is what I’ve come up with so far:

Thanks so much in advance!! I really appreciate it :slight_smile:


#2

Hey @yesvirginia,

Cool that you’re practicing and trying to write a URL shortener. Can you describe what exactly isn’t working when you’re POST-ing a new URL?

I seem to get an expected response:

{"data":{"_id":"5b5e73524f9dab0052750e7f","originalUrl":"https://google.ca","shorterUrl":"845"}}

Also, when I hit api/shorturl/845, it correctly redirects to Google.


#3

Yeah, I fixed it a few hours after posting here and TOTALLY forgot to update here!!