Cannot POST /api/shorturl

Just starting the URL Shortener microservices project. Can’t get past this point.

Here’s my

A few things I’ve done already:

  • MongoDB / Mongoose versions are installed/in package.json and up to date (from here)

  • bodyParser is required and working (from here

  • originally had no forward slash in URL…I fixed this. have tried “/api/shorturl/new” and “/api/shorturl” and neither works

  • have tried swapping for app.get and neither has worked

A few ideas based on the forum:

What is the access function here? It seems like I just haven’t gotten to this point at the project yet.

Fixing parameters? I am not sure here. I already think I fixed issues with bodyParser.

Ideas/thoughts? Totally stuck.

The url in your html file: <form action="api/shorturl" method="POST"> should match the url in server.js:"/api/shorturl/new", ...)

If you change the url in your html file to api/short/url/new (the same as in server.js), you will see the output of anything you type in the form when you click “POST URL”.

Thank you so much! This fixed it!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.