NodeJS TwitchAPI online/offline status
<p>I am trying to check Streams are Online or Offline...</p>

<p>But I have 1 problem this request is not required for all users.. only 1 or max 2 when 1 is from it online and 1 is offline...</p>

<p>Here is  an example:
In the MySQL are 3 Streams
test1
test2
test3
test4
(1, 2, 3 and 4 are the streams...)
(when ALL offline my output is this...)
test4 is offline and this 4times.</p>

<p>Script:</p>

<pre><code>var request = require('request');
var cheerio = require('cheerio');
var parser = require('json-parser');
var JSON = require('JSON');
var mysql  = require('mysql');

var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'status',
  password : '',
  database : 'all_channels'
});

connection.query("SELECT * FROM channels", function(error, rows, response, fields) {
    if (!!error) {
        console.log('Error in Query!');
    } else {
        for(var i in rows) {


console.log(rows[i])
                request('https://api.twitch.tv/kraken/streams/'+rows[i].channels+'?client_id=(I have removed the ID from intent)', function (error, response, html) {
        var profileyt = JSON.parse(html);


if (profileyt["stream"] !== null) {
                        console.log(profileyt["stream"]["channel"]["status"]);
                    } else {


request('https://api.twitch.tv/kraken/channels/'+rows[i].channels+'?client_id=(I have removed the ID from intent)', ', function (error, response, html) {
                            var profiletest = JSON.parse(html);


console.log(''+profiletest["display_name"]+' is offline');
})
}})}}});
</code></pre>

<p>Console Output:
C:\Bot>node test2.js</p>

<pre><code>RowDataPacket { channels: 'test1', status: 'offline' }
RowDataPacket { channels: 'test2', status: 'offline' }
RowDataPacket { channels: 'test3', status: 'offline' }
RowDataPacket { channels: 'test4', status: 'offline' }

Test4 ist offline
Test4 ist offline
Test4 ist offline
Test4 ist offline
</code></pre>

<p>I have spent 2-3 days trying to fix it but I still have no idea...</p>