Bookends update – April 2019

It’s a beautiful day in San Francisco, I got up and made some coffee today. I wrote a short tutorial on how to serve Vue.js apps through Github Pages and then I stepped away from the computer for a bit. But now, I’ve been sitting at my computer for about 2 hours and I have barely anything to show for it except a list Stack Overflow answers that were the correct answers for the questions but my problem was not solved by them.

So a few days ago, I finally got book search and user accounts working on Bookends. You can check it out here: bookends.app. So after this, I wanted to try something else. I want to be able to track a book when I’m reading it and update the progress as I go on and mark it finished at the end. There are a few new things for me to consider, one is making a composite table of users and their books, this proved to be a simple enough exercise thanks for Sequelize.

Next, I wanted to start tracking through the UI. And this is where I’m just flabbergasted! Okay so this is my route:

/api/tracking/start?bookId=[id]&userId=[id]

Simple enough, so I tried it in Postman, works as expected. I try accessing the page and it works as expected. Then I tried to put it on the Bookpage so when a user clicks “Start reading” the book gets tracked…

Well, I thought this would work but it didn’t. And well, fair enough, our good ole pal CORS was what I thought was causing the issue because usually that’s what messes up local dev if you’re serving Vue.js on one post and the server on another port. Well, after spending about an hour trying differen things, cleaning up my routes and looking at each character in my URL to make sure I’m not making a dumb human mistake, it turned out that it wasn’t the issue.

The issue was that for some reason, express routing doesn’t work past the 2nd nesting…I’m not even sure if that’s a legit problem. But at some point, I decided to try this URL instead:

/api/tracking-start

And bam! No cors issues, no network errors, and everything worked. 😐

I’m frustrated with some basic things about Express.js and Node.js together and I’m wondering how long my patience will last. The small jolts of energy I get from getting something work are cool but I don’t know when the negatives will outweigh those.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.