<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Synchronous requests [solved]]]></title><description><![CDATA[<p dir="auto">I am just working on some changes in my Wunderlist module and have a problem caused by not knowing JavaScript enough…</p>
<p dir="auto">One instance of my module can display multiple Wunderlist lists. In order for that to work I have to do one requests for every list to the Wunderlist API.</p>
<pre><code> request({url: "https://a.wunderlist.com/api/v1/tasks?list_id=" + id, method: "GET", headers: {"X-Access-Token": this.config.accessToken,"X-Client-ID": this.config.clientID}}, function(error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
      ....
      callback(tasks);
 }
});
</code></pre>
<p dir="auto">My problem is I can’t think of a way to combine the todos from all those requests into a single array and then after all todos are received send them to the interface.</p>
]]></description><link>https://forum.magicmirror.builders/topic/77/synchronous-requests-solved</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 12:27:18 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/77.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 May 2016 12:06:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Synchronous requests [solved] on Fri, 13 May 2016 12:03:32 GMT]]></title><description><![CDATA[<p dir="auto">And there comes the <code>“Doh!” moment</code>! :D Thanks completely overlooked that…</p>
]]></description><link>https://forum.magicmirror.builders/post/622</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/622</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Fri, 13 May 2016 12:03:32 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Fri, 13 May 2016 07:57:20 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I looked into it, and it really is pretty simple and obvious when I’ll explain you. So prepare for a “Doh!” moment … ;)</p>
<p dir="auto">Right before you do the request to WunderList, you empty the items array:<br />
<a href="https://github.com/paviro/MMM-Wunderlist/blob/master/fetcher.js#L38" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/paviro/MMM-Wunderlist/blob/master/fetcher.js#L38</a></p>
<p dir="auto">Then if Wunderlist responds, you fill the items array with new items.</p>
<p dir="auto">This means that as long as your fetcher is waiting for wunderlist to respond, the items array is empty. If in the meantime an other fetcher is finished fetching, it uses the items array to make a full list. But that array is then still empty, waiting to be filled after the wunderlust response.</p>
<p dir="auto">The solution? Move line 38 (<code>items = [];</code>) to line 51 (above <code>for (var i = 0; i &lt; JSON.parse(body).length; i++) {</code>).</p>
<p dir="auto">Thats all! :)</p>
]]></description><link>https://forum.magicmirror.builders/post/611</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/611</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Fri, 13 May 2016 07:57:20 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 14:42:17 GMT]]></title><description><![CDATA[<p dir="auto">Thanks! :)</p>
]]></description><link>https://forum.magicmirror.builders/post/540</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/540</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 14:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 14:41:50 GMT]]></title><description><![CDATA[<p dir="auto">Will fork your module tomorrow and give it a try.</p>
]]></description><link>https://forum.magicmirror.builders/post/539</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/539</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Thu, 12 May 2016 14:41:50 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 14:10:40 GMT]]></title><description><![CDATA[<p dir="auto">I am on it but I can’t find the problem… :confounded:<br />
When <code>broadcastItems</code> is fired and therefore <code>fetcher.onReceive</code> triggered the lists are populated.  But once <code>broadcastTodos()</code> collects the tasks by looping over the <code>fetchers</code> some lists appear to be empty. Any chance you could have a <a href="https://github.com/paviro/MMM-Wunderlist/commit/d326c5596e0bfd6fc83a4dea74c589b440b85843" target="_blank" rel="noopener noreferrer nofollow ugc">look</a>?</p>
]]></description><link>https://forum.magicmirror.builders/post/537</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/537</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 14:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 13:27:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paviro" aria-label="Profile: paviro">@<bdi>paviro</bdi></a> try debugging the Fetchet on the same way. ;)</p>
]]></description><link>https://forum.magicmirror.builders/post/531</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/531</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Thu, 12 May 2016 13:27:15 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 13:26:37 GMT]]></title><description><![CDATA[<p dir="auto">It is not the socket connection. The fetcher sometimes returns an empty list :/</p>
]]></description><link>https://forum.magicmirror.builders/post/530</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/530</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 13:26:37 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 13:25:47 GMT]]></title><description><![CDATA[<p dir="auto">I’m on my phone now, so not really able to explain the callbacks. Will do that later.</p>
<p dir="auto">Regarding the empty lists: try debugging by putting some log statements on places where You receive and send data.</p>
]]></description><link>https://forum.magicmirror.builders/post/529</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/529</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Thu, 12 May 2016 13:25:47 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 13:22:26 GMT]]></title><description><![CDATA[<p dir="auto">Does work great now! The only problem is sometimes a list is empty on a refresh even tough it should not be :/</p>
<pre><code class="language-javascript">{ inbox: [],
  'ViRO Entertainment': 
   [ 'Todo1',
     'Todo2',
     'Todo3' ]
 }
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/528</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/528</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 13:22:26 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 12:51:44 GMT]]></title><description><![CDATA[<p dir="auto">I do not quite understand how the <code>itemsReceivedCallback</code>works :confused:</p>
]]></description><link>https://forum.magicmirror.builders/post/526</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/526</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 12:51:44 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 12:49:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/paviro" aria-label="Profile: paviro">@<bdi>paviro</bdi></a> Yeah, but try to understand what I did. Thats the best way to learn. Let me know what you don’t understand. I’ll explain.</p>
]]></description><link>https://forum.magicmirror.builders/post/525</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/525</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Thu, 12 May 2016 12:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 12:47:32 GMT]]></title><description><![CDATA[<p dir="auto">I won’t pretend I completely understand what you did there :sweat_smile:<br />
Is it okay if I copy that code, I managed to modify it in a way that seems to work :)</p>
]]></description><link>https://forum.magicmirror.builders/post/524</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/524</guid><dc:creator><![CDATA[paviro]]></dc:creator><pubDate>Thu, 12 May 2016 12:47:32 GMT</pubDate></item><item><title><![CDATA[Reply to Synchronous requests [solved] on Thu, 12 May 2016 12:17:28 GMT]]></title><description><![CDATA[<p dir="auto">Take a look at how I did this with the newsfeed.</p>
<p dir="auto">There is a <code>Fetcher</code> object that gets instantiated for every newsfeed. As soon as this feed receives new data it stores it in an instance variable and calls a function of the node_helper (see line 52 of the node helper).</p>
<p dir="auto">That function then retrieves the  the values of all the Fetchers’ instance variables and combines the data. It then sends the socket notification with the combined data.</p>
]]></description><link>https://forum.magicmirror.builders/post/523</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/523</guid><dc:creator><![CDATA[MichMich]]></dc:creator><pubDate>Thu, 12 May 2016 12:17:28 GMT</pubDate></item></channel></rss>