# Trying a different approach to the project and ran into a wall \[SOLVED\] - Feedback requested

**URL:** <https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940>\
**Category:** I Built This\
**Created:** [September 7, 2016, 9:55pm UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940 "2016-09-07T21:55:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chadicus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chadicus/32/164999_2.png) [@chadicus](https://forum.freecodecamp.org/u/chadicus)\
**Post date:** [September 7, 2016, 9:55pm UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940/1 "2016-09-07T21:55:39Z")

</div>

Hey Hey -  
After looking at the previous projects and reviewing the API docs, I decided to approach the project a bit differently. Most are declaring an array with the channels as array elements. In my mind this didn’t seem very useful, so I decided to first use the search api to find a relevant channel (no problem there) and display the results (again, no problem there). I’m having a hell of a time figuring out how to then call the streams api and get the status added to each channel object. I think I need to do something with promises, or deferred objects, but I can’t quite get it…

Here is the pen…  
[http://codepen.io/chadagate-1471204219/pen/GjRvXN](http://codepen.io/chadagate-1471204219/pen/GjRvXN?editors=0010)

I’ve removed all of the rendering code, and am just trying to see if I can get the online property added to the array of channel objects… Any advice, hints, or comments are appreciated!

Chad

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [September 7, 2016, 10:32pm UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940/2 "2016-09-07T22:32:34Z")

</div>

Hey, the problem is, that calling getJSON (async function) inside your for loop will mess things up. Have a look here: [http://stackoverflow.com/questions/11488014/asynchronous-process-inside-a-javascript-for-loop](http://stackoverflow.com/questions/11488014/asynchronous-process-inside-a-javascript-for-loop)

---

<div class="post-metadata">

**Author:** ![chadicus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chadicus/32/164999_2.png) [@chadicus](https://forum.freecodecamp.org/u/chadicus)\
**Post date:** [September 8, 2016, 2:09am UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940/3 "2016-09-08T02:09:16Z")

</div>

Thanks for that @BenGitter ! I tumbled down a rabbit hole trying to figure that one out, burned up a whole day! I’ll be able to wrap this project up tonight…

---

<div class="post-metadata">

**Author:** ![chadicus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chadicus/32/164999_2.png) [@chadicus](https://forum.freecodecamp.org/u/chadicus)\
**Post date:** [September 8, 2016, 2:25pm UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940/4 "2016-09-08T14:25:11Z")

</div>

Okay, I’ve wrapped up my Twitch project. I don’t love the fact that i needed to use setTimeout to get the channels streaming status properties added to the channel objects. It feels like there is a WAY better way to do that. I’m going to spend some time reading about promises and closures in javascript, I believe that may be the better way to get it done. Any feedback is appreciated!

[Twitch Project Pen](http://codepen.io/chadagate-1471204219/full/GjRvXN/)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:08pm UTC](https://forum.freecodecamp.org/t/trying-a-different-approach-to-the-project-and-ran-into-a-wall-solved-feedback-requested/34940/5 "2021-06-01T18:08:08Z")

</div>


