Day 3
I should point out that I’m hardly working flat-out on this! Yesterday I was working on it at the code pod meetup, so my pace has been fairly leisurely. Today I’m grabbing an hour while the family’s out. Have completely lost track of the actual time spent. Maybe do pomodoros?
09:47
I’m probably at the point when I should start on the API, I’m going to revisit my pattern from the wiki viewer and try to complete some kind of call/response. Need to use the FCC workaround, it seems.
Day 4
Day 4 is actually several calendar days later, since I’ve had childcare and family days in between. So my flow is broken a bit and that’s something I need to watch. I can’t help these breaks in focus, but I need to plan for them better, maybe have specific notes to step into, and preferably have something fun and/or straightforward to do on resumption.
Right now I have neither of those things since I’m right at the beginning of a new section (the API) and I’m not clear how to proceed, and don’t have a decent run in terms of time, either. Well, at least I’ll try to get myself set up for next time.
Log
I’m going to generalise my API call/promise pattern into a github gist right now.
I’ve copied this into the twitch viewer and added the heroku proxy prefix to bypass CORS issues, and replaced the base twitch API url with the one provided by FCC.
It is returning something that looks like it has the data I need. I just need to parse it out and figure how to incorporate it into the app. Still don’t really get the CORS stuff or how promises are properly used.
Working in github pages.
Now the drill is charged, so I am obliged to resume my DIY chores.
Log
Evening now. Realised the query url I was using has a placeholder for callbacks in it. Took that out and looked again at the FCC workaround page. Looks like I have 3 calls I can make:
- users
- channels
- streams
And I think I’ll have to make different calls at different times to fulfill these user stories.
Right now I’m thinking call one at init to get the avatar and whatnot (the ‘static’ user info) and then calls on the streams for subsequent updates/filter refreshes etc.
Maybe I should curry the basic query function to return variants on the string… but then do I need different ways of dealing with the responses?
need something like:
const userNameArray = ['medrybw', 'freecodecamp', 'femfreq', 'lootbndt', 'spitchell'];
controller.init () {
getAllUserData(userNameArray)
},
getAllUserData(array){
array.forEach(user){
submitQuery('https://cors-anywhere.herokuapp.com/wind-bow.gomix.me/twitch-api/streams/' + user).then(function(response) {
localStorage.setItem(user, response));
}
}
…Well anyway, decided not to use localStorage (yet), but I got this working pretty well!
I have real data from api responses pushing into an array of objects on the data
property accounts
and the view will render a chunk of HTML from an _js file for each. Current problem is to get view.render
to run only when all the data is collected.
Another promise?
Then I need to write the refresh function and get stream-data and then add logic that acts on whether the stream is live or not.