UnhandledPromiseRejection

UnhandledPromiseRejection
0

#1

Hi everybody,

I’m working on the nightlife project and I’ve run into trouble when users try to submit their registration form. I believe the problem relates to the this: every time I run npm run devstart the following gets logged in the console.

(node:75216) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Username contains an illegal unescaped character (node:75216) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How can I find this unhandled promise? I’ve searched my code for “username” but can’t seem to find it.


#2

Okay, I figured out that the problem was with Mongoose. They recently updated to 5.0.0 and I guess that caused some issues. I’ve now hardcoded the uri with the username and password, but obviously that isn’t very smart. I’ve been using dotenv, but now I can’t seem to get it to work.

If anyone’s more familiar with the newest Mongoose, how can I store my username and password safely and access them?