These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Apr 2018
:wave:
Brad
@bradtaniguchi
Apr 24 2018 00:16 UTC
Peace
Stephen James
@sjames1958gm
Apr 24 2018 00:21 UTC
Should we really get in to the old discussion
@brittanyrutherford My first computer used paper tape :)
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 00:22 UTC
:O how's that?
Brad
@bradtaniguchi
Apr 24 2018 00:25 UTC
@sjames1958gm geezus
Stephen James
@sjames1958gm
Apr 24 2018 00:30 UTC
@bradtaniguchi geezer :)
Joseph
@revisualize
Apr 24 2018 01:52 UTC
@sjames1958gm I finally got that shit!
Stephen James
@sjames1958gm
Apr 24 2018 01:52 UTC
@revisualize Woo Hoo?
@sjames1958gm I've been sitting at my desk with like $22 in change playing with how to give back change.
Stephen James
@sjames1958gm
Apr 24 2018 01:54 UTC
@revisualize :+1:
Joseph
@revisualize
Apr 24 2018 01:57 UTC
There was something that I needed to buy but, I forget what it is.
This is annoying.
Remember that you have to buy something but can't remember what it is.
Must not be that important.
eeflores
@eeflores
Apr 24 2018 02:02 UTC
a fidget spinner
Joseph
@revisualize
Apr 24 2018 02:06 UTC
@eeflores If I ever buy a fidget spinner. You have permission to kick me in the baby maker ... Really hard.
eeflores
@eeflores
Apr 24 2018 02:07 UTC
:wink:
Pedro Diaz
@Pjdaze
Apr 24 2018 02:48 UTC
can anyone tell me why i get NaN here
const oil = Oil.map(x => x.LyeSapValue)
console.log(oil) // [ 0.191, 0.1337, 0.1328 ]

const lyeTotal = oil.map(y => y * sum);
console.log(lyeTotal) // [ NaN, NaN, NaN ]
Ken Haduch
@khaduch
Apr 24 2018 02:53 UTC
@Pjdaze - what is sum?
Pedro Diaz
@Pjdaze
Apr 24 2018 02:55 UTC
lol
i was just gonna comeback to say i forgot sum lol
anthonygallina1
@anthonygallina1
Apr 24 2018 06:41 UTC
Hello World
Jefferson
@jeffersonnnn
Apr 24 2018 12:15 UTC
hi guys, i am still stuck with how to implement the intent (for sharing) feature with React in the Random Quote Machine challenge. Please help :'(
Nate Mallison
@NJM8
Apr 24 2018 12:57 UTC
@jeffersonnnn I don't think you need anything special about react to share a tweet, it can be done with a simple api call
Here is mine:
  // send quote and author out to twitter
  function tweetIt () {
    const phrase = document.getElementById('phrase').innerText;
    const author = document.getElementById('author').innerText;
    const tweetUrl = 'https://twitter.com/intent/tweet?text=' +
    encodeURIComponent(phrase) + " " + encodeURIComponent(author);
    console.log(tweetUrl);
    window.open(tweetUrl);
  }
Moisés Man
@moigithub
Apr 24 2018 13:55 UTC
react way.. could be creating a component.. and maybe store/place the content (phrase author) in a state
or probably hold that data on parent.. and create a function/dumb/presentational component and pass data via props
const TweetIt = (props) => (<a href={props.content}>Tweet</a>)
Jason Luboff
@JLuboff
Apr 24 2018 15:15 UTC
:alien:
Christopher McCormack
@cmccormack
Apr 24 2018 15:20 UTC
@JLuboff yo
Jason Luboff
@JLuboff
Apr 24 2018 15:20 UTC
Yo. Real dick move bro. :P
Christopher McCormack
@cmccormack
Apr 24 2018 15:26 UTC
it's not that bad - I could have added your email address!
if I knew it
Jason Luboff
@JLuboff
Apr 24 2018 15:30 UTC
@cmccormack I think it shows if you hover over my picture?
Or I'm pretty sure it shows on my github lol
Hell.. you could probably guess it
Christopher McCormack
@cmccormack
Apr 24 2018 15:32 UTC
Jason Luboff
@JLuboff
Apr 24 2018 15:38 UTC
Ya...go with that
Christopher McCormack
@cmccormack
Apr 24 2018 15:38 UTC
haha
did you learn react from that pen?
Jason Luboff
@JLuboff
Apr 24 2018 15:40 UTC
....I still haven't gone fully through it :'(
Christopher McCormack
@cmccormack
Apr 24 2018 15:41 UTC
No worries man just wanted to see if it would be helpful to someone who hasn't worked with it
Jason Luboff
@JLuboff
Apr 24 2018 15:42 UTC
I'll aim to go through it this week
sabahatullah
@sabahatullah
Apr 24 2018 15:48 UTC
how comes I can't trigger click on the tabs
image.png
I have tried click() and trigger('click')
and mousedown as well. nothing seems to be working
Jason Luboff
@JLuboff
Apr 24 2018 15:49 UTC
@sabahatullah We'll need a lot more information than that
Christopher McCormack
@cmccormack
Apr 24 2018 15:50 UTC
@sabahatullah share some code
sabahatullah
@sabahatullah
Apr 24 2018 15:52 UTC
when the tab is clicked it saves the tab text in the local storage and then with the following line I am trying to trigger click on the respective tab
var LS = localStorage.getItem('_tabActive').trim();
$(".nav-tabs li:contains("+LS+")").click();
and to confirm yes the local storage is working/saving the text for example it contains "Overview"
@JLuboff @cmccormack let me know if you need any more info
Christopher McCormack
@cmccormack
Apr 24 2018 15:56 UTC
Did you log the value in LS and confirm you get the correct element when using your query selector before trying to click?
This is an overcomplicated way to do this, btw.
I'm also confused - when you click a tab you want it to save to local storage then click itself? That will infinite loop if you aren't careful
sabahatullah
@sabahatullah
Apr 24 2018 15:58 UTC
is it.. basically all I want is to "save" the last clicked tab so the next time when user lands on the page that tab is opened by default
at the moment it defaults back to the first tab
so if a user clicks on Booking, the next time user lands on this page, Booking tab should be opened
sabahatullah
@sabahatullah
Apr 24 2018 16:07 UTC
@cmccormack does it make sense?
Christopher McCormack
@cmccormack
Apr 24 2018 16:08 UTC
ah so the second line isn't actually inline
May Kittens Devour Your Soul
@diomed
Apr 24 2018 16:09 UTC
:cookie: :cookie:
Christopher McCormack
@cmccormack
Apr 24 2018 16:10 UTC
so think about it this way - what makes your tabs work? When you click a tab, does it change a css class on the body to make it active while others are not, thus hidden? Do tabs have a click handler that does this work? If so, then maybe call this handler instead of actually forcing a click event on a tab
sabahatullah
@sabahatullah
Apr 24 2018 16:11 UTC
yes it a bootstrap tabs functionality I guess. It add an active class to the respective tab on click
could you please tell how do you mean "call this handler"
Christopher McCormack
@cmccormack
Apr 24 2018 16:14 UTC
Bootstrap uses javascript for tabs, may be a good idea to read through the details https://getbootstrap.com/docs/4.0/components/navs/#via-javascript

@sabahatullah when I refer to handler I simply mean a function that is invoked when some event is triggered. An example would be something like

function handleClick(event) { 
   /* some code using click event */
}
...
$('#mybutton').click(handleClick)

You can ready more about jQuery click events and handlers in their docs https://api.jquery.com/click/

sabahatullah
@sabahatullah
Apr 24 2018 16:23 UTC
okay so I think I need to find that event listener in js files. but to be honest I am still thinking as to why it is not triggering a click on a button.
Christopher McCormack
@cmccormack
Apr 24 2018 16:24 UTC
@sabahatullah :point_up: April 24, 2018 8:56 AM
sabahatullah
@sabahatullah
Apr 24 2018 16:24 UTC
regardless of what it already has. All I am doing is to simulate a mouse click event
@cmccormack yes I can see LS grabs the corrent tab text
Christopher McCormack
@cmccormack
Apr 24 2018 16:25 UTC
@sabahatullah it should work using .click but only if your selectors are accurate and your local storage was done properly. Log every step of the way to make sure the data is accurate
sabahatullah
@sabahatullah
Apr 24 2018 16:26 UTC
image.png
Christopher McCormack
@cmccormack
Apr 24 2018 16:26 UTC
@sabahatullah ok then add a log statement for $(".nav-tabs li:contains("+LS+")") above your $(".nav-tabs li:contains("+LS+")").click(); code and see if it returns the proper element
@sabahatullah might be easier to just use the id of the tab, btw
then you can reference it directly
sabahatullah
@sabahatullah
Apr 24 2018 16:27 UTC
sure let me quickly add IDs
sabahatullah
@sabahatullah
Apr 24 2018 16:32 UTC
let me actually show you the whole code

var $ = jQuery;
$(document).ready(function(){
console.log('hello');
if($(".company-cover-header").length > 0){
$(".nav-tabs li").click(function(){
var active = $(this).text().trim();
localStorage.setItem('_tabActive', active);
});
}

var LS = localStorage.getItem('_tabActive').trim();
console.log(LS) // It works
$(".nav-tabs li:contains("+LS+")").click();

});

heading off now. will give that a go later
@cmccormack thanks for your help so far
Christopher McCormack
@cmccormack
Apr 24 2018 16:34 UTC
np
Stephen James
@sjames1958gm
Apr 24 2018 16:41 UTC
@sabahatullah Is there a class that gets assigned to the selected tab that you could set rather than fake out a click?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 16:58 UTC
hi guys
am trying to use handlebars
and use {#each ..
Christopher McCormack
@cmccormack
Apr 24 2018 16:58 UTC
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 16:58 UTC
inside the each, I am getting a value, but it's not what I want, so am trying to send this value to a webservice, and get it back
@cmccormack yeah
so basically, my problem is that I have some kind of a loop, where I need to call the webservice for each record in the loop
Christopher McCormack
@cmccormack
Apr 24 2018 17:01 UTC
I've not used handlebars but I'm not sure why you would call the service from your html
maybe helpers?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:06 UTC
well
it won't work
helpers assume the data is already there
when i checked on handlebars site, people suggested that, but handlebars authors said it goes against the principle of mvc
where u need to get ur data in controllers, and pass it to the view
so am trying to get my data all together before passing it to the view (handlebars)
i think am about to make that work
Christopher McCormack
@cmccormack
Apr 24 2018 17:07 UTC
I would think that you should do it that way as well
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:07 UTC
so am looping through the result, and making calls, then updating the result
Christopher McCormack
@cmccormack
Apr 24 2018 17:07 UTC
handlebars should be presentational mainly
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:11 UTC
here's my code:
function getUserName(data){
$.each(data.d.results, function(index, element){
     let url = "url for web service(passingurl and element); 
    $.ajax({
                  url: url, 
                 method: 'GET', 
                 headers: {
                  'accept': 'application/json; odata=verbose' 
                   }     , 
               success: function(result){
                              data.d.results[index]["Sponsor"] = result.d.Title; 
                   }, 
                 fail: function(err){
                            console.log(err); 
                 }
}); 
}

}
so when I try to call getUserName function, how do I get an indicator that ALL the records were updated?
like.. an indicator that the success part is done
Christopher McCormack
@cmccormack
Apr 24 2018 17:13 UTC
you can log it in your success function
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:13 UTC
yeah, but I mean
not an indicator as a log
i am going to call the getUserName function right
and am going to pass the data
it will loop through the data.d.results array
and for each one in these records, it will make a web service call
and update a value
how do I know, as an outside function, that this whole process was done, so I can pass the update "data" to handlebars?
i wanna use promises
but not sure how it would work here
Christopher McCormack
@cmccormack
Apr 24 2018 17:15 UTC
yup use promises
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:15 UTC
but where?
if i put it on the success, it will return when the first record got updated
i want when all of them are updated, then get back to me
Christopher McCormack
@cmccormack
Apr 24 2018 17:15 UTC
you can use Promise.all
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:15 UTC
ah
Christopher McCormack
@cmccormack
Apr 24 2018 17:16 UTC
I haven't needed to use promises directly like this in a while but it should work, return the Promise.all then use the return promise.then
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:20 UTC
well
ummm
so
it kinda worked but
i don't want to have n number of resolves :(
for example:
Promise.all([promise1, promise2, promise3]).then(function(values) {
  console.log(values);
});
I am passing the array of promises
i am returning this whole promise.all
if i do promise.then on my main function, it will generate a then for each one
i don't think u get what am trying to do
it's ok nevermind
Christopher McCormack
@cmccormack
Apr 24 2018 17:26 UTC
@brittanyrutherford I thought you needed to know when they were all successful no?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:26 UTC
yeah, but how does that apply to my main function
Christopher McCormack
@cmccormack
Apr 24 2018 17:27 UTC
you would call whatever depends on them being completed from your Promise.all().then scope
so if you need to update an indicator you can do it there
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:28 UTC
function getUserName(data){
let promises = []; 
$.each(data.d.results, function(index, element){
     let url = "url for web service(passingurl and element"); 
    let promise = $.ajax({
                  url: url, 
                 method: 'GET', 
                 headers: {
                  'accept': 'application/json; odata=verbose' 
                   }     , 
               success: function(result){
                              data.d.results[index]["Sponsor"] = result.d.Title; 
                   }, 
                 fail: function(err){
                            console.log(err); 
                 }
}); 
promises.push(promise);
Promise.all(promises).then(function(values){
    resolve(data);
});
}

}
Christopher McCormack
@cmccormack
Apr 24 2018 17:28 UTC
However be careful as you are updating all of your values within each promise, so if one fails you have still modified your state
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:28 UTC
that's my new code
how do I use the getUserName method?
Christopher McCormack
@cmccormack
Apr 24 2018 17:29 UTC
return the promise.all and use something like
getUserName(data).then((results) => // do something here after all promises resolved )
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:30 UTC
ah
Christopher McCormack
@cmccormack
Apr 24 2018 17:30 UTC
I would not recommend this: $.each(data.d.results, function(index, element){
may be better to pass data.d.results to your getUserName function
and instead of using jquery just use Array map
you can map your ajax call to return an array of promises then return Promise.all(arrayofpromises)
also you aren't actually using promises properly
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:32 UTC
it doesn't recognize resolve(data)
it says resolve is not defined
Christopher McCormack
@cmccormack
Apr 24 2018 17:32 UTC
you should use the Promise constructor
new Promise( /* executor */ function(resolve, reject) { ... } );
resolve is done within the Promise callback
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:33 UTC
so new Promise.all() .. /
?
Christopher McCormack
@cmccormack
Apr 24 2018 17:33 UTC
so in your success and fail methods
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:35 UTC
am not sure how I can use Promise.all as a regular promise
Christopher McCormack
@cmccormack
Apr 24 2018 17:37 UTC
Promise.all takes a callback function, you can use that callback to update whatever indicator you need
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:38 UTC
but i dont to update
i want to return
the updated value
something like return Promise.all[promises]);
Christopher McCormack
@cmccormack
Apr 24 2018 17:39 UTC
Your code above is modifying an object in place as part of your success function
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:39 UTC
then on the other side, getUserName(data).then(function(newdata){});
i know but
how do I tell getUserName to return the updated data
?
i need a promise wrapping the promise.all?
Christopher McCormack
@cmccormack
Apr 24 2018 17:40 UTC
Do you mean the actual data? You'll have to change your current success and fail functions as those are modifying your data object in place ( bad behavior )
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:41 UTC
uh :( ur not getting what am saying
nevermind
Christopher McCormack
@cmccormack
Apr 24 2018 17:41 UTC
Promises work with resolve and reject - what you pass to those callbacks will be what the promise carries into the .then
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:41 UTC
it's ok.. nevermind
thanks anyway @cmccormack
Christopher McCormack
@cmccormack
Apr 24 2018 17:42 UTC

sorry but you didn't ask a question, you just said

i need a promise wrapping the promise.all?

Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:42 UTC
what I was saying is ...
I have a function
getUserName
am passing an array to it
the array makes async calls
so am pushing the promise for each call into a small array calls promises
then after the loop, am doing: Promise.all([smallarray-of-promises]).then(function(values){} ;
Christopher McCormack
@cmccormack
Apr 24 2018 17:43 UTC
Do you have updated code? The last code you shared did not do that
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:44 UTC
it does
here it is again
```
function getUserName(data){
let promises = []; 
$.each(data.d.results, function(index, element){
     let url = "url for web service(passingurl and element"); 
    let promise = $.ajax({
                  url: url, 
                 method: 'GET', 
                 headers: {
                  'accept': 'application/json; odata=verbose' 
                   }     , 
               success: function(result){
                              data.d.results[index]["Sponsor"] = result.d.Title; 
                   }, 
                 fail: function(err){
                            console.log(err); 
                 }
}); 
promises.push(promise);
Promise.all(promises).then(function(values){
    resolve(data);
});
}

}
```
so now, I have Promise.all(promises) ..
how do I return this
Christopher McCormack
@cmccormack
Apr 24 2018 17:44 UTC
You can't just call a variable a promise
you have to create a Promise
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:44 UTC
on mozilla docs
they're using it just like that
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:45 UTC
how about this
they didn't declare an object, they just used it
Christopher McCormack
@cmccormack
Apr 24 2018 17:45 UTC
Right but you didn't actually create an array of Promises
Brad
@bradtaniguchi
Apr 24 2018 17:45 UTC
hello world
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:45 UTC
I did
let promises = [];
at the top
then promises.push(promise);
hi @bradtaniguchi
Christopher McCormack
@cmccormack
Apr 24 2018 17:46 UTC
you created an array of $.ajax jqXHR objects
yes but that isn't how you create a promise!
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:46 UTC
but the return of $.ajax is a promise
right?
Christopher McCormack
@cmccormack
Apr 24 2018 17:46 UTC
Ah I see
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:46 UTC
so when I call it, it'll return a promise that's stored in the array
so I have an actual array of promises
Christopher McCormack
@cmccormack
Apr 24 2018 17:47 UTC
so you are using the Ajax call as your Promise, I was assuming you wanted to create your own and specify what constitues reject/resolve
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:47 UTC
no
am good for the .ajax part
Brad
@bradtaniguchi
Apr 24 2018 17:47 UTC
function getUserName(data) {
  let promises = [];
  $.each(data.d.results, function(index, element) {
          let url = "url for web service(passingurl and element");
      let promise = $.ajax({
          url: url,
          method: 'GET',
          headers: {
              'accept': 'application/json; odata=verbose'
          },
          success: function(result) {
              data.d.results[index]["Sponsor"] = result.d.Title;
          },
          fail: function(err) {
              console.log(err);
          }
      }); 
      promises.push(promise); 
      Promise.all(promises).then(function(values) {
          resolve(data);
      });
  }

}
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:47 UTC
now for the last part
Brad
@bradtaniguchi
Apr 24 2018 17:47 UTC
Whats up with the promise.all being in the $.each, is that correct?
Christopher McCormack
@cmccormack
Apr 24 2018 17:47 UTC
I would recommend you don't use the ajax as your promise but instead wrap the ajax call in a promise and reject/resolve the values you want
Nate Mallison
@NJM8
Apr 24 2018 17:48 UTC
I second that
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:48 UTC
@bradtaniguchi I want to loop through items in an array, and make calls to a webservice
Brad
@bradtaniguchi
Apr 24 2018 17:48 UTC
Ah ok
Christopher McCormack
@cmccormack
Apr 24 2018 17:48 UTC
@bradtaniguchi haha good catch, didn't see it with the formatting above
@brittanyrutherford your Promise.all should be outside your .each
Brad
@bradtaniguchi
Apr 24 2018 17:49 UTC
I mean it looks to me tho each promise.all call is being used for each result
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:49 UTC
@cmccormack yeah, I have it now outside
my actual code now looks like this:
```
function getUserName(data) {
  let promises = [];
  $.each(data.d.results, function(index, element) {
          let url = "url for web service(passingurl and element");
      let promise = $.ajax({
          url: url,
          method: 'GET',
          headers: {
              'accept': 'application/json; odata=verbose'
          },
          success: function(result) {
              data.d.results[index]["Sponsor"] = result.d.Title;
          },
          fail: function(err) {
              console.log(err);
          }
      }); 
      promises.push(promise); 

  }
 Promise.all(promises).then(function(values) {
          resolve(data);
      });

}
but again .... :(
how do I return the updated data passed to the function back again to the caller function?
Christopher McCormack
@cmccormack
Apr 24 2018 17:50 UTC
Promise.all does not use resolve/reject
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:50 UTC
so how do I return the data :joy:
we're going around the main point
:joy:
Christopher McCormack
@cmccormack
Apr 24 2018 17:51 UTC
We aren't you're just not reading what we're saying :)
Read the Promise docs, see how they work first
otherwise this will be guess and check
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:51 UTC
i know how it works
but Promise.all
?
I am used to Promise like with ajax
Christopher McCormack
@cmccormack
Apr 24 2018 17:51 UTC
having a resolve in your Promise.all tells me you do not
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:52 UTC
let promise = $.ajax... then promise.then (function(value) {} ).catch(function(somethingelse){}); ...
because I don't know how promise.all work, never used it, but that doesn't mean i don't know promises ........
Christopher McCormack
@cmccormack
Apr 24 2018 17:52 UTC
I mean technically you could just iterate over values and use .then on each one to do something
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:53 UTC
but I just want to return 1 value ..
which is the one I passed already
Christopher McCormack
@cmccormack
Apr 24 2018 17:53 UTC
which value do you want?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:54 UTC
data, the one i passed to the getUserName function
i modified it as part of the loop
now i wanna return it
Nate Mallison
@NJM8
Apr 24 2018 17:56 UTC
@brittanyrutherford I think you aren't returning anything from your success function in the ajax call. do the modification then return data.d.results
then :
 Promise.all(promises).then(function(values) {
          console.log(values);
      });
should log data.d.results
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 17:59 UTC
@NJM8 so the $1M question is.. how do I return it to the caller function?
i don't want to use the result in the same function, i wanna take it to the caller function
Christopher McCormack
@cmccormack
Apr 24 2018 17:59 UTC
when dealing with promises, you don't
you pass a callback function that does the work you wanted
it's asynchronous
Nate Mallison
@NJM8
Apr 24 2018 18:00 UTC
you mean the function that called getUserName?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:00 UTC
but . that doesn't make sense @cmccormack
I want to be able to do something like getUserName(data).then(function(updatedData) ...
Christopher McCormack
@cmccormack
Apr 24 2018 18:01 UTC
you haven't really exlained why you want to be returned
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:01 UTC
this should be how promises work
Christopher McCormack
@cmccormack
Apr 24 2018 18:01 UTC
returning Promise.all should work for this
Nate Mallison
@NJM8
Apr 24 2018 18:01 UTC
wait wait, do you mean the function that called getUserName?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:01 UTC
because there , in the main function, is where I format the data and call other functions, then pass it to handlebars
@NJM8
as I said in the beginning
am formatting the data, etc..calling this getUserName.. I want to return that data, so I can pass it to handlebars
so something like getUserName(data).then(function(updateData){ //do handlebars stuff })
Christopher McCormack
@cmccormack
Apr 24 2018 18:03 UTC
you should be able to just return Promise.all([array of promises])
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:03 UTC
that's what I did.. and u said i don't know how to use promises :/ and i said i don't know how promise.all work :/ :/
Christopher McCormack
@cmccormack
Apr 24 2018 18:03 UTC
:point_up: April 24, 2018 10:30 AM which I stated a while back
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:04 UTC
u said return array of promises :/
Nate Mallison
@NJM8
Apr 24 2018 18:05 UTC
you have an array of users?
and you are getting their user names from some service?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:05 UTC
@NJM8 it's an array of projects.. each project has a property called sponsor ID..
I want to make a call to the DB to get the actual username based on the user ID
Nate Mallison
@NJM8
Apr 24 2018 18:06 UTC
ok, where is this code running? client side?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:06 UTC
@NJM8 yeah
@ndburrus thanks
Nate Mallison
@NJM8
Apr 24 2018 18:07 UTC
I would forget ajax and promise all and move straight to async await, it's getting too complex for what you need
Norvin Burrus
@ndburrus
Apr 24 2018 18:07 UTC
@brittanyrutherford you're welcome! enjoy :sparkles:
Christopher McCormack
@cmccormack
Apr 24 2018 18:07 UTC
@brittanyrutherford the part I'm really not understanding is what you wanted to do with the results of each ajax call - you say you want to return the data but you're already modifying the data in place in your ajax call. If you just want to check if it's completed, pass your callback that does something with the completed data to Promise.all()
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:07 UTC
@cmccormack really am not sure what's hard about that
I am passing data to a function
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:07 UTC
the data contains sponsors IDs
i want to get the sponsor names as well
so am making ajax calls, getting sponsor names, and adding these to each record int he array
then i wanna return the whole thing
Nate Mallison
@NJM8
Apr 24 2018 18:08 UTC
also if you are wanting to pass off data to the view that needs to happen after all the calls so await async is perfect
Christopher McCormack
@cmccormack
Apr 24 2018 18:08 UTC
async await is promises @NJM8 just prettier
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:09 UTC
@NJM8 thanks, i'll check it out
Nate Mallison
@NJM8
Apr 24 2018 18:10 UTC
https://github.com/NJM8/RithmSchool-Advanced-Javascript-Part-2/blob/master/asyncAwaitExercises.js, start at line 43, same thing you are doing just use fetch instead of request as this is server side. then send the results array off to handle bars
Christopher McCormack
@cmccormack
Apr 24 2018 18:10 UTC
@brittanyrutherford what do you do with the returned object? lets say you could just return the modified object from your function, what would be next?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:10 UTC
@cmccormack next would be to pass it to handlebars
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:10 UTC
Hi guys, you all seems active today
:)
Christopher McCormack
@cmccormack
Apr 24 2018 18:10 UTC
@brittanyrutherford how so?
is there a method you invoke to do this?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:11 UTC
yeah
in handlebars
i get the template
then pass the modified data to the template
Christopher McCormack
@cmccormack
Apr 24 2018 18:11 UTC
then you can pass that method to your Promise.all().then
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:11 UTC
i don't want to do that
because
i don't want to use the getUserName to draw handlebars html
i want it to just pass it array of projects, and return me the same array with project sponsor added to each project
THEN
pass the result to another function that draws handlebars
because, i am doing more than just this function
i have handlebars helpers
and i "might" need to call other async methods to do other stuff
Christopher McCormack
@cmccormack
Apr 24 2018 18:12 UTC
that's fine, you just need to add the next function in your chain as the callback then
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:12 UTC
like the project manager
so no way to return it? solution is to chain it inside the getUserName function?
anywayz, it's ok
i'll check async await
Christopher McCormack
@cmccormack
Apr 24 2018 18:15 UTC
Async Away returns a promise fyi
@brittanyrutherford so what would be the next step after your Promise.all() resolves?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 18:16 UTC
i feel like u r trolling me now @cmccormack :/
i said like 5 times, i wanna call handlebars
nevermind
i'll go
thanks a lot
Christopher McCormack
@cmccormack
Apr 24 2018 18:17 UTC
I'm not trolling you literally said a few minutes ago you don't want to call handlebars immediatly
Maybe I wasn't clear about the callback part - if you handlbars drawing is done in a function, and you pass that function to your Promise.all().then(callback), that function will be invoked after all promises resolved, passing the results to the callback
Christopher McCormack
@cmccormack
Apr 24 2018 18:30 UTC
@brittanyrutherford I made an example, is this similar to what you wanted to do?
@RoniqueRicketts yo
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:34 UTC
@cmccormack wazzup?
Christopher McCormack
@cmccormack
Apr 24 2018 18:35 UTC
nm man just playing with https://cssgridgarden.com and working atm
Nate Mallison
@NJM8
Apr 24 2018 18:36 UTC
playing and working
living the dream
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:36 UTC
I am here messign with my little project
Christopher McCormack
@cmccormack
Apr 24 2018 18:39 UTC
What are you workign on?
this.project
Christopher McCormack
@cmccormack
Apr 24 2018 18:41 UTC
Cool you have the backend stuff started I see
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:42 UTC
@cmccormack started hehe that all. started
Christopher McCormack
@cmccormack
Apr 24 2018 18:42 UTC
woah don't forget to add node_modules to your .gitignore!
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:42 UTC
@cmccormack mf wont go away
Christopher McCormack
@cmccormack
Apr 24 2018 18:43 UTC
remove the leading /
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:43 UTC
gonna try it
Christopher McCormack
@cmccormack
Apr 24 2018 18:44 UTC
you may also need to do git rm -r --cached school-backend/node_modules or somethign like that
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:53 UTC
that bitch wont move
Christopher McCormack
@cmccormack
Apr 24 2018 18:54 UTC
did you do the command above?
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:55 UTC
fatal: /node_modules: '/node_modules' is outside repository
Stephen James
@sjames1958gm
Apr 24 2018 18:56 UTC
@RoniqueRicketts /node_modules would be in the root directory of your file system. You need a relative directory path
Christopher McCormack
@cmccormack
Apr 24 2018 18:56 UTC
are you doing it from the root of your repo?
@sjames1958gm man you're fast :)
Stephen James
@sjames1958gm
Apr 24 2018 18:56 UTC
@cmccormack When you have made ALL of the mistakes ...
Christopher McCormack
@cmccormack
Apr 24 2018 18:56 UTC
@sjames1958gm do you have alerts setup for error messages like that?? haha
@sjames1958gm fair point
Stephen James
@sjames1958gm
Apr 24 2018 18:57 UTC
By you I mean me :)
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:57 UTC
@cmccormack yes from the same folder I did the initial gitinit
Stephen James
@sjames1958gm
Apr 24 2018 18:57 UTC
Then no leading /
Christopher McCormack
@cmccormack
Apr 24 2018 18:58 UTC
can you paste the command you used exactly @RoniqueRicketts ?
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:58 UTC
@sjames1958gm fatal: pathspec 'node_modules' did not match any files
$ git rm -r --cached node_modules
fatal: pathspec 'node_modules' did not match any files
Stephen James
@sjames1958gm
Apr 24 2018 18:58 UTC
@RoniqueRicketts if you cannot do ls node_modules
Christopher McCormack
@cmccormack
Apr 24 2018 18:58 UTC
that isn't the command I used
:)
git rm -r --cached school-backend/node_modules notice the path
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:59 UTC
oh FK I am in the frontend hahahahahaahahahahaaaa
Christopher McCormack
@cmccormack
Apr 24 2018 18:59 UTC
haha
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 18:59 UTC
@cmccormack I am on a call at work talking to a customer while on here :)
Christopher McCormack
@cmccormack
Apr 24 2018 19:00 UTC
jeeze careful not to $ rm -rf / :)
Brad
@bradtaniguchi
Apr 24 2018 19:01 UTC
I knew a guy that ran sudo rm -rf / some-folder and relized to late as his computer imploded
Christopher McCormack
@cmccormack
Apr 24 2018 19:01 UTC
ouch
Stephen James
@sjames1958gm
Apr 24 2018 19:01 UTC
That's why you never log in as root
Christopher McCormack
@cmccormack
Apr 24 2018 19:01 UTC
I wonder if rimraf has checks that specifically avoid that
Stephen James
@sjames1958gm
Apr 24 2018 19:02 UTC
@bradtaniguchi OUCH
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:06 UTC
For the love of God! Nude_modules is still showing. Auugh
Brad
@bradtaniguchi
Apr 24 2018 19:08 UTC
ooohh nude_modules :sunglasses:
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:11 UTC
its just there showing itself, showing things only I should see. My nude_modules is giving trouble.
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 19:18 UTC
@cmccormack it's ok i got it
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:19 UTC
Fixed hehehehehe> I am free to code now my nude_modules are gone. hehehe
@cmccormack @sjames1958gm thanks bosses!!! POW!! Check out my project now all my nude_modules are hidden. WOOP WOOP!! https://github.com/RoniqueRicketts/my-school-app
@sjames1958gm @cmccormack thanks
Why can't I give brownies? :(
Stephen James
@sjames1958gm
Apr 24 2018 19:22 UTC
@RoniqueRicketts Because of your nude modules :)
Christopher McCormack
@cmccormack
Apr 24 2018 19:22 UTC
@RoniqueRicketts what did it take?
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:22 UTC
@sjames1958gm lol but they are hidden now
Stephen James
@sjames1958gm
Apr 24 2018 19:22 UTC
@RoniqueRicketts That's good - Family Friendly
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:23 UTC
@cmccormack I pushed using my command line instead of my my github desktop program.
@sjames1958gm family friendly???
Christopher McCormack
@cmccormack
Apr 24 2018 19:24 UTC
git should be done in terminal only /purist
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:25 UTC
@cmccormack for real but I am Lazy I use to do it all through terminal but then I saw pretty interface and ran to it. But I don't mind running it all from the terminal
Brad
@bradtaniguchi
Apr 24 2018 19:25 UTC
I tried to use the github desktop.... I gave up cuse I had no idea how to do anything.
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 19:27 UTC
@bradtaniguchi lol I know a little of both. I should just keep with the terminal then. AUUGH u all spoil sport. Terminal fixed it btw.
Jason Luboff
@JLuboff
Apr 24 2018 20:06 UTC
Never even tried the github desktop..
Brad
@bradtaniguchi
Apr 24 2018 20:07 UTC
its confusing AF
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:07 UTC
@JLuboff its cool but I can jump back to the terminal.
Jason Luboff
@JLuboff
Apr 24 2018 20:09 UTC
I know atom and VS have built in git integration...but I've never bothered to use it
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:10 UTC
@JLuboff are you serious? I never checked that out
What are you learnign today btw?
Christopher McCormack
@cmccormack
Apr 24 2018 20:10 UTC
I used it a bit in VS Code but I ran into small issues with it. It was great for diffs though
Jason Luboff
@JLuboff
Apr 24 2018 20:10 UTC
Ya I imagine most text editors and IDE's have it built in
Uhhhh... not sure. I haven't had much of a chance to do any learning today heh. I did modify a stored procedure earlier to include an if/else with a nexted if. So..that was something. But I actally just got back to work, was gone for 3.5 hours
Christopher McCormack
@cmccormack
Apr 24 2018 20:17 UTC
Fell asleep under your desk with a water bottle as a pillow @JLuboff ?
Jason Luboff
@JLuboff
Apr 24 2018 20:18 UTC
@cmccormack I wish! My office is too messy for naps :(
I had to go watch the baby while my wife took care of some things
Christopher McCormack
@cmccormack
Apr 24 2018 20:18 UTC
What a great daddy
:)
Jason Luboff
@JLuboff
Apr 24 2018 20:19 UTC
:P
He was a menace most of the time...but I came out of it stronger!
Christopher McCormack
@cmccormack
Apr 24 2018 20:20 UTC
Can he walk yet?
Jason Luboff
@JLuboff
Apr 24 2018 20:22 UTC
Nah... he just turned 5 months yesterday
Christopher McCormack
@cmccormack
Apr 24 2018 20:22 UTC
I don't have any kids so I have no idea if that's too young to walk :)
Jason Luboff
@JLuboff
Apr 24 2018 20:22 UTC
Doesn't crawl either. He is trying but doesn't quite get how to move about and lift himself right
They start walking between 9 and 15 months, average being around 13-14 months (I just looked it up)
Christopher McCormack
@cmccormack
Apr 24 2018 20:23 UTC
Bring him to a large downhill road and push him like a baby bird! He'll learn to crawl that way
It's basically how I learned to swim :D
Jason Luboff
@JLuboff
Apr 24 2018 20:24 UTC
Haha...don't think his mom would appreciate me doing that
Christopher McCormack
@cmccormack
Apr 24 2018 20:24 UTC
yeah... don't suppose she would
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:25 UTC
@JLuboff lies he was messing aroung for 3.5 hours. naughty
@cmccormack go get some babies man. make one tonight
Christopher McCormack
@cmccormack
Apr 24 2018 20:26 UTC
no babies, babies make too many gross fluids
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:31 UTC
@JLuboff next time bring your wife to Jamaica and feed her some Real Native Jamaican food that child will start crawling in 5 months.
@cmccormack lol how to swim lmao. hahahaa
Jason Luboff
@JLuboff
Apr 24 2018 20:32 UTC
@cmccormack You get used to it. I've been peed on, spit up on, drooled on, got poop on me.....its actually suprised how little it's bothered me lol
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:32 UTC
@cmccormack you make gross fluids too. hehehe. Go make a baby bruv its good for you. L)
Jason Luboff
@JLuboff
Apr 24 2018 20:32 UTC
@RoniqueRicketts Send me some jerk chicken!
Christopher McCormack
@cmccormack
Apr 24 2018 20:32 UTC
You will never convince me! I like my free time :D
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:32 UTC
@JLuboff bruv yuh affi come fah!
@cmccormack Lol but you should make a mini Christopher.
Jason Luboff
@JLuboff
Apr 24 2018 20:33 UTC
Ya... free time is limited.. pretty much just the evenings after he goes to bed (i.e post 8:30 PM)
Christopher McCormack
@cmccormack
Apr 24 2018 20:33 UTC
The world just isn't ready for two of me
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:33 UTC
@cmccormack hahaha.
I think I should get 14 Juniors :)
Jason Luboff
@JLuboff
Apr 24 2018 20:34 UTC
@RoniqueRicketts Brah..it's like $600/person round trip! I'll go to Hawaii for $100/person less and a lot shorter trip
@cmccormack Come on now, everyone will be like "Oh the baby looks just like you"
Christopher McCormack
@cmccormack
Apr 24 2018 20:34 UTC
Great so I can feel even worse my kid has a giant head and nose haha
Jason Luboff
@JLuboff
Apr 24 2018 20:35 UTC
:joy: :joy:
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:35 UTC
@JLuboff I am talking about our native herbs to make a stong baby. A baby that will arm wrestle you at 5 months. ;)
Jason Luboff
@JLuboff
Apr 24 2018 20:35 UTC
@RoniqueRicketts Which type of herbs? We talking the herb herb?
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:35 UTC
@cmccormack Don't mind the head and nose, go make them kids bruv
Jason Luboff
@JLuboff
Apr 24 2018 20:35 UTC
Or like... rosemary
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:36 UTC
@JLuboff many herbs. or a variety of a particular herb. wink wink
Stephen James
@sjames1958gm
Apr 24 2018 20:36 UTC
Jamaican herbs?
Jason Luboff
@JLuboff
Apr 24 2018 20:36 UTC
The many herbs are legal here but the ladies, they can not have that (while pregnant/breastfeeding). You don't want the baby getting it ;)
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:37 UTC
@sjames1958gm I thought you said you were sleeping at work :)
@JLuboff Not smoking herbs. Some herbs for strength. :) so that the baby get some strength from mother. And we also have a particular fruit for @cmccormack so even at 90 years old he can still make a son. :)
Christopher McCormack
@cmccormack
Apr 24 2018 20:39 UTC
haha
Jason Luboff
@JLuboff
Apr 24 2018 20:41 UTC
Ah
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 20:49 UTC
If I wanna use Passportjs just for username and password do I get passport local or just passport? I am confused.
Jason Luboff
@JLuboff
Apr 24 2018 20:51 UTC
you need both
passport local is the strategy
Essentially you have passport, and then a corresponding strategy/s)
Amit Patel
@AmitP88
Apr 24 2018 21:01 UTC
hey guys, what do you think of my Twitch Channels project? https://amitp88.github.io/Twitch-Channels/
I just finished making it responsive :)
Christopher McCormack
@cmccormack
Apr 24 2018 21:11 UTC
@AmitP88 hey looks great! However I think you're missing a user story
Amit Patel
@AmitP88
Apr 24 2018 21:12 UTC
@cmccormack I am?
Christopher McCormack
@cmccormack
Apr 24 2018 21:12 UTC

Three. User Story: I can see whether Free Code Camp is currently streaming on Twitch.tv.

Five. User Story: if a Twitch user is currently streaming, I can see additional details about what they are streaming.

Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 21:12 UTC
@JLuboff ok cool. So I install passport then I should add a strategy
Christopher McCormack
@cmccormack
Apr 24 2018 21:13 UTC
That's weird I put the right numbers next to the quote but it still renumbered it
Amit Patel
@AmitP88
Apr 24 2018 21:14 UTC
@cmccormack oh yeah, I've actually fulfilled those stories. If any channel is online, then the topic of the stream is automatically rendered. If offline, the topic is rendered as "offline"
Christopher McCormack
@cmccormack
Apr 24 2018 21:14 UTC
@AmitP88 your layout looks really nice - have you considered using CSS grid? I've been playing with it today and it's perfect for your kind of layout
@AmitP88 incorrect - status does not mean the channel is online
Amit Patel
@AmitP88
Apr 24 2018 21:15 UTC
@cmccormack I've been thinking about it. I want to learn both css flexbox and grid (although I know a bit of flexbox)
@cmccormack ??? I thought it was
Christopher McCormack
@cmccormack
Apr 24 2018 21:16 UTC
@AmitP88 check out FreeCodeCamps actual stream from the api - notice it's null https://wind-bow.glitch.me/twitch-api/streams/freecodecamp
@AmitP88 OgamingSC2 is streaming however, and you can see more details https://wind-bow.glitch.me/twitch-api/streams/ogamingsc2
Amit Patel
@AmitP88
Apr 24 2018 21:18 UTC
@cmccormack this is weird, because I thought I did that in my jquery code:
$(document).ready(function() {
    var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];

    for(var i = 0; i < channels.length; i++) {
      $.ajax({
        'url' : 'https://wind-bow.gomix.me/twitch-api/channels/' + channels[i] + '?callback=?',
        'type': 'GET',
        'dataType': 'json',
        'success': function(data) {
          // console.log(data);

          var status_light;

          if (data.status === null) {
            data.status = "offline";
            status_light = 'class="offline"';
          } else {
            status_light = 'class="online"';
          }

          $("#streamers").append(
            '<tr ' + status_light + '>' +       
              '<td class="channel_logo_cell">' + '<img src=' + "'" + data.logo + "'" + 'class="channel_logo"' + '/>' + '</td>' +
              '<td>' + '<a href=' + data.url + ' ' + 'target=_blank' + ' ' + 'class="channel_name"' + '>' + data.display_name + '</a>' + '</td>' +
              '<td>' + '<h3>' + data.status + '</h3>' + '</td>' +
            '</tr>'
          );
        }
      });    
    }
});
Christopher McCormack
@cmccormack
Apr 24 2018 21:18 UTC
@AmitP88 I don't see where you're calling the streams api
Amit Patel
@AmitP88
Apr 24 2018 21:19 UTC
@cmccormack I'm confused. I thought I was calling it in my ajax call
Christopher McCormack
@cmccormack
Apr 24 2018 21:19 UTC
that's the channels api
'https://wind-bow.gomix.me/twitch-api/channels/' vs
'https://wind-bow.gomix.me/twitch-api/streams/'
Amit Patel
@AmitP88
Apr 24 2018 21:21 UTC
@cmccormack hmmm, so I should switch the urls? or do I need to make a separate ajax function just for the streams?
Christopher McCormack
@cmccormack
Apr 24 2018 21:21 UTC
yup separate call - this is a good exercise to learn how to nest asynchronous calls so I recommend you try to implement it
Jason Luboff
@JLuboff
Apr 24 2018 21:23 UTC
@RoniqueRicketts You need to install both
And require/import both
Amit Patel
@AmitP88
Apr 24 2018 21:24 UTC
@cmccormack hmmm, I'm thinking how should I put this into my app though. because I have 3 td cells in each row: the channel logo, the channel name, and the channel status
do I need a 4th td? or should I replace channel status td?
Christopher McCormack
@cmccormack
Apr 24 2018 21:24 UTC
@AmitP88 Whatever you need to do in order to fulfill the user stories :)
Amit Patel
@AmitP88
Apr 24 2018 21:26 UTC
@cmccormack looks like the data.status was just a placeholder. I need to switch it to /streams
Christopher McCormack
@cmccormack
Apr 24 2018 21:27 UTC
Status is more like "working on blah today" than describing their streaming status
Amit Patel
@AmitP88
Apr 24 2018 21:29 UTC

so for freecodecamps channel, the url would be this?

https://wind-bow.glitch.me/twitch-api/streams/freecodecamp/?callback=?

Christopher McCormack
@cmccormack
Apr 24 2018 21:30 UTC
not sure if you need jsonp do you?
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 21:30 UTC
@JLuboff i shall
Christopher McCormack
@cmccormack
Apr 24 2018 21:30 UTC
?callback=? is a jquery specific option for parsing a call as jsonp
Amit Patel
@AmitP88
Apr 24 2018 21:30 UTC
oh yeah, nvm. I have the chrome extension
Christopher McCormack
@cmccormack
Apr 24 2018 21:30 UTC
@AmitP88 but yes that is the url for streaming
@AmitP88 not sure what you mean by that
Amit Patel
@AmitP88
Apr 24 2018 21:31 UTC
@cmccormack oh I have the JSON Formatter chrome extension
Christopher McCormack
@cmccormack
Apr 24 2018 21:31 UTC
that isn't really related to what I was saying though
unless it's changing your url for you maybe?
Amit Patel
@AmitP88
Apr 24 2018 21:32 UTC
lol Idk man, I'm kinda lost atm
Christopher McCormack
@cmccormack
Apr 24 2018 21:35 UTC
@AmitP88 which part?
Amit Patel
@AmitP88
Apr 24 2018 21:35 UTC
@cmccormack just with everything. Feels like my brain shutdown atm lol
Christopher McCormack
@cmccormack
Apr 24 2018 21:35 UTC
you've already done an api call, now you just make another one with a slightly different url
Amit Patel
@AmitP88
Apr 24 2018 21:36 UTC
I know, but I'm wondering if I should get rid of the status part since it's not an indicator if they're streaming or not (which I originally thought it was)
Christopher McCormack
@cmccormack
Apr 24 2018 21:36 UTC
I was just informing you that you do not need to add callback=? to your call - that is used for jQuery to make JSONP (not JSON) calls, and you do not need that for this api
@AmitP88 why not add lots of details :)
no reason you can't add more
Amit Patel
@AmitP88
Apr 24 2018 21:37 UTC
lol that's true
ok, I'll take a short break, then come back to it. I feel like I need to sort of reset haha
Christopher McCormack
@cmccormack
Apr 24 2018 21:38 UTC
you could possibly break up a user row into two rows and add streaming detail on the alternate row
Ronique Ricketts
@RoniqueRicketts
Apr 24 2018 21:40 UTC
@JLuboff so must I use the passport-http is that necessary?
Christopher McCormack
@cmccormack
Apr 24 2018 21:40 UTC
no
Jason Luboff
@JLuboff
Apr 24 2018 21:41 UTC
Nope... not even sure what the is for lol
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 21:45 UTC
hey guys, anyone used jspdf?
Jason Luboff
@JLuboff
Apr 24 2018 21:48 UTC
Nope
Pretty neat library though
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 21:49 UTC
yeah it's nice
but not well documented
Seems like a lot of docs
There's also a live demo
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 21:51 UTC
yeah, but some functions don't behave as expected, and people just experiment
for example, the link u sent is missing the addImage function
Jason Luboff
@JLuboff
Apr 24 2018 21:52 UTC
That sounds like my experience with a lot of modules :joy: experiment until you get somewhere
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 21:52 UTC
and how to use it
Jason Luboff
@JLuboff
Apr 24 2018 21:54 UTC
Look through the source code :D
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 21:57 UTC
oh
the geeky way
Jason Luboff
@JLuboff
Apr 24 2018 21:57 UTC
Thats how you have to do it sometimes
Brad
@bradtaniguchi
Apr 24 2018 21:57 UTC
sometimes ... its the only way
Jason Luboff
@JLuboff
Apr 24 2018 22:00 UTC
I mean...if you don't like to read the docs, ya
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 22:14 UTC
so I was reading the .js file, but how can u understand and keep track of how it works, when it's 700 lines of code?
Jason Luboff
@JLuboff
Apr 24 2018 22:15 UTC
Thats the challenge! You have to follow all the paths haha
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 22:16 UTC
i was stuck for 10 secs on & to figure out it means &
on & amps
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:35 UTC
I wrote code that included ES6, it works fine with chrome (for sure), when I tried to run it on IE11, it didn't work, I took the code and pasted it on babel playground, and took the generated ES5 code, and it didn't work as well
something like Promise.. wasn't recognized by IE
as far as I know, IE11 supports ES5, how come babel generates code that isn't supported by IE?
Brad
@bradtaniguchi
Apr 24 2018 23:39 UTC
#IETroubles
maybe give it a try on netscape navigator
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:40 UTC
??
Christopher McCormack
@cmccormack
Apr 24 2018 23:41 UTC
@brittanyrutherford Google Promise Polyfill
nothing, making jokes
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:41 UTC
i found babel polyfill
Christopher McCormack
@cmccormack
Apr 24 2018 23:41 UTC
are you using babel?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:41 UTC
nope
I was just writing code in es6
tried the result in IE
errors everywhere
Christopher McCormack
@cmccormack
Apr 24 2018 23:42 UTC
there may be a way to import babel polyfill not sure, but there might be something smaller for just Promises
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:42 UTC
arrow functions, template literals
even let keyword didn't work
so I was using this Promise.all .. and it's giving me the issues now
is there a way to reference a polyfill with a script tag?
Christopher McCormack
@cmccormack
Apr 24 2018 23:43 UTC
@brittanyrutherford maybe try <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@7/dist/polyfill.min.js"></script>
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:43 UTC
ahaa
Christopher McCormack
@cmccormack
Apr 24 2018 23:44 UTC
hmm not sure if you can polyfill let
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:44 UTC
do I need to do anything else on the page?
i mean, polyfill works automatically?
Christopher McCormack
@cmccormack
Apr 24 2018 23:44 UTC
You have two things to work with when working with older browsers - Polyfills and Transpilers
Polyfills basically replicate something that looks like a function within JS - like Promises
Transpilers basically take more modern code and rewrite it so it works in older browsers (eg let becomes var with something to help with scope, maybe)
I think the polyfill should work automagically, haven't tested it though
You may look into setting up a toolchain using babel or something similar for your future projects, I do most of my coding now with Webpack/babel so it can take care of all the transpiling and I can write the most modern code if I choose to and it will still work in older browsers with some config settings
Jason Luboff
@JLuboff
Apr 24 2018 23:47 UTC
I'm currently building an app that I have to have support for IE11...so I just write everything client side with ES5... not ideal..but..until we get rid of all the old computers it'll have to do
Most people don't know how to get to IE11 on Windows 10 :trollface:
Christopher McCormack
@cmccormack
Apr 24 2018 23:48 UTC
@JLuboff and IE11 isn't even all THAT bad - older versions are hell
Jason Luboff
@JLuboff
Apr 24 2018 23:48 UTC
Eh... it's just a pain how IE handles things, especially intranet pages
It will by default run in IE 7( or 8, can't remember) mode unless you specify in the head of the html file to run in EDGE mode
Christopher McCormack
@cmccormack
Apr 24 2018 23:49 UTC
yuck
Jason Luboff
@JLuboff
Apr 24 2018 23:50 UTC
Yuck indeed
Christopher McCormack
@cmccormack
Apr 24 2018 23:50 UTC
Even with babel I never did get one of my projects running on older versions. Either babel didn't work properly or something else, no idea
things we take for granted don't work at all in older stuff
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:50 UTC
@cmccormack thanksss! yeah referencing that works automatically
Christopher McCormack
@cmccormack
Apr 24 2018 23:50 UTC
like you couldn't use the property default on any objects
@brittanyrutherford good to know! I might use it just to prevent issues in the future
Ok gotta go make dinner see you later!
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:51 UTC
am using freakin visual studio :( too hard to setup the front-end toolchains
Brad
@bradtaniguchi
Apr 24 2018 23:54 UTC
vs code?
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:54 UTC
and surprise.. handlebars itself doesn't work right away on ie11
@bradtaniguchi no, visual studio community, the IDE
Jason Luboff
@JLuboff
Apr 24 2018 23:55 UTC
I'm using handlebars without issue in ie11...but I'm serving it all from the backend
Brad
@bradtaniguchi
Apr 24 2018 23:55 UTC
Ah I see
Brittany Rutherford
@brittanyrutherford
Apr 24 2018 23:55 UTC
handlebars using array.find
that's weird ..
looks like I grabbed the latest version, which has this code.. i remember i used it before with IE no issues