Can anyone give some advice on how to structure/refactor my code please? To be specific, I’m attempting to refactor the routes.js file createAndInsertUrl (line 62) and where it’s used in line 90, but got wrapped up in spaghetti code and callbacks. It’s currently returning undefined for the uniqueIdCount, which I believe is due to the createAndInsertUrl running before the uniqueIdCount is returned. I’m a bit lost with where to go next.
I had the whole thing working from one file, but wanted to refactor it to best practices… problem is, I’m not well practiced!