How debugging can look like šŸ›

Madelene Trang
3 min readDec 8, 2021

--

Markus Winkler on Unsplash

It is week 17 in the bootcamp, and we are diving into the backend sprint and learning how to build RESTful APIā€™s. In order to do that I am working with a database. For my project I picked a database consisting of Netflix titles, each object contains 12 properties that I can use to define routes/endpoints (aka the path the user will take to find a specific Netflix title, or collection of Netflix titles based on the given key and value). Exciting! I know šŸ˜Š.

In this database there is a unique id for each Netflix title and I wanted to create an endpoint that would lead the user to a specific Netflix title based on that id.

- here is an example of an object in the data collection ( a single netflix title).

I started writing the endpoint below and used the array method find(), that would lead to a specific title. But for some reason, when testing this in the browser, it didnā€™t work, I just got my error status 404 ā€˜ No shows/movies found with that IDā€™.ā€¦and so the detective work began šŸ•µļø. What was I missing ? Why could I not find that specific Netflix title? I needed to trace back, and go through my code step by step.

A snippet showing the endpoint that should return a single object based on the key ā€˜show_idā€™

After going through the material, trying different alternatives, googling to figure this out, it turns out that the key show_id is a string. Even though at first glance it looks like numbers, it is in fact a string shown by a simple console.log ({show_id}).

Look at this wolf in a sheepā€™s clothingā€¦.

To convert this from a string to a number, I just simply needed to add a + in front of the show_id on line 41.

And here you have it, a object found based on a unique ID!

It is crazy how much issue a tiny plus sign can cause, but when you finally solve it, you will feel amazing.ā€¦.. nothing really beats this feeling and most importantly it is a lesson that stays. A natural part of the coding journey. Now on to finding my next lesson and bug to squishšŸ›!

--

--

Madelene Trang

Software developer who loves a good cup of coffee, lo-fi playlists all while creating beautiful and sustainable websites.