DEV Community

Timothy Nguyen
Timothy Nguyen

Posted on

SDC Day 5

I spent this day building out the endpoints for my API. I was able to get the data to match exactly to the API I used during FEC. The toughest endpoint was definitely styles. It was difficult because of the nested one-to-many relationship that it requires. I need a list of styles for a product id and another list of photos and skus for each style! What I did was use Promise.all to start a query for each style's photos. In the then() block I would then loop over the results and attach them to the associated styles. I repeated this process for the skus. There must be a better way...

Top comments (0)