I have issues with my API. My shorturl allocator is broken. Here is the link
When I try to POST a url, the response that comes back does not include the
short_url property. It only returns the
original_url and the url submitted.
That is the problem. Whatever I try I cannot get the property.
I reviewed your code and honestly it kind of a mess. I strongly suggest you review the mongoose challenges. You seem to be making something as simple as connecting to the database and finding a record more complicated than necessary. You are not using what was taught in the challenges. You also seem to not understand when and when not to use
Remember any method that returns a promise needs to be handled with either the
then method or if you want to use
async/await, you must use
await before the call and the parent function must be
async. You have several instances where you are not using
await when you should be and you have some situations where you are using
await but not within an
I suggest you add some console.log statements through your code to figure out what variables contain.
Also, I suggest learning how to properly indent code to make it easier for other users and yourself to read through your code.