<?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[Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27;]]></title><description><![CDATA[<p dir="auto">As we all know, the Nodejs module “request” is deprecated.<br />
I like to rewrite my node_helper.js module so request is not used anymore. Instead the Nodejs module “got” will be used.</p>
<p dir="auto">Module: <a href="https://github.com/htilburgs/MMM-MyPrayerTimes" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/htilburgs/MMM-MyPrayerTimes</a></p>
<p dir="auto">Can someone help me on my way?<br />
I’m not a developer and just do it for fun.</p>
]]></description><link>https://forum.magicmirror.builders/topic/18813/need-help-for-rewrite-node_helper-js-from-request-to-got</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 09:43:28 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/18813.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Jun 2024 18:39:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Thu, 27 Jun 2024 19:22:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
;-)</p>
]]></description><link>https://forum.magicmirror.builders/post/118518</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118518</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Thu, 27 Jun 2024 19:22:15 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Thu, 27 Jun 2024 18:53:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> ignore. I tried async didn’t help</p>
]]></description><link>https://forum.magicmirror.builders/post/118517</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118517</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 27 Jun 2024 18:53:16 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Thu, 27 Jun 2024 18:03:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
Sam, you put a comment in node_helper.js.<br />
I don’t understand what you mean.</p>
<p dir="auto">//  don’t need this anymore with async below</p>
]]></description><link>https://forum.magicmirror.builders/post/118516</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118516</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Thu, 27 Jun 2024 18:03:48 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Tue, 25 Jun 2024 19:57:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> no rush  at your availability.</p>
]]></description><link>https://forum.magicmirror.builders/post/118470</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118470</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 25 Jun 2024 19:57:07 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Tue, 25 Jun 2024 19:52:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
Hi Sam, thanks in advance. I’m not at home right now and I only have my smartphone. I cannot test, but I’ll try it in a day.</p>
<p dir="auto">I’ll let you know!!</p>
]]></description><link>https://forum.magicmirror.builders/post/118469</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118469</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Tue, 25 Jun 2024 19:52:19 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Tue, 25 Jun 2024 15:13:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a>   I made a couple changes to the Js and added comments to the node_helper, but all looks ok …</p>
]]></description><link>https://forum.magicmirror.builders/post/118463</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118463</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 25 Jun 2024 15:13:23 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Tue, 25 Jun 2024 04:03:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> ok, I’ll look at it first thing in the morning</p>
]]></description><link>https://forum.magicmirror.builders/post/118456</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118456</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 25 Jun 2024 04:03:37 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Tue, 25 Jun 2024 03:50:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> published it. Didn’t know how than on Master.</p>
]]></description><link>https://forum.magicmirror.builders/post/118455</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118455</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Tue, 25 Jun 2024 03:50:43 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 22:17:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> if you push the repo I’ll look at it…  you can do it on a separate branch to not disturb the existing</p>
]]></description><link>https://forum.magicmirror.builders/post/118452</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118452</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 24 Jun 2024 22:17:19 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 22:14:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
In the previous version with ‘request’ I used JSON.parse() and got the same results.<br />
The module works, but I didn’t know for sure if I used the correct approach.</p>
]]></description><link>https://forum.magicmirror.builders/post/118451</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118451</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Mon, 24 Jun 2024 22:14:00 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 22:07:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> the response.json() function returns a js object  already parsed.</p>
<p dir="auto">thst is what yiy were going to fo w JSON.parse().  but don’t need to.</p>
<p dir="auto">I don’t know if the CONTENT of the object is correct, but it should be for the same request</p>
]]></description><link>https://forum.magicmirror.builders/post/118450</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118450</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 24 Jun 2024 22:07:19 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 21:24:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
That I don’t understand.<br />
Is this a problem? What would be better?</p>
]]></description><link>https://forum.magicmirror.builders/post/118449</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118449</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Mon, 24 Jun 2024 21:24:16 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 20:58:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> depends on what you mean by correct.</p>
<p dir="auto">it returns the parsed text as an object<br />
not text.</p>
]]></description><link>https://forum.magicmirror.builders/post/118448</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118448</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 24 Jun 2024 20:58:05 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 20:37:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
As far as I can see this works the correct way.<br />
Do you agree?</p>
]]></description><link>https://forum.magicmirror.builders/post/118447</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118447</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Mon, 24 Jun 2024 20:37:33 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 20:27:00 GMT]]></title><description><![CDATA[<p dir="auto">@htilpburgs I was going to say the result of json() is passed already</p>
]]></description><link>https://forum.magicmirror.builders/post/118446</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118446</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 24 Jun 2024 20:27:00 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 20:08:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">I kept on searching and think I’ve found it.<br />
I didn’t use JSON.parse(), but simply put it in the result</p>
<pre><code>    this.sendSocketNotification('MPT_RESULT', result.data.timings);
</code></pre>
<p dir="auto">It works, but I hope this is the right way.</p>
]]></description><link>https://forum.magicmirror.builders/post/118445</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118445</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Mon, 24 Jun 2024 20:08:34 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Mon, 24 Jun 2024 19:49:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">Oké, made a start.<br />
Changed my node_helper.js to:</p>
<pre><code>/*
//-------------------------------------------
MMM-MyPrayerTimes
Copyright (C) 2019 - H. Tilburgs
MIT License
//-------------------------------------------
*/

const NodeHelper = require('node_helper');

module.exports = NodeHelper.create({

  start: function() {
          console.log("Starting node_helper for: " + this.name);
  },

 getMPT: function(url) {
        // Make a GET request using the Fetch API
        fetch(url)
        .then(response =&gt; {
        if (!response.ok) {
          throw new Error('Network response was not ok');
        }
        return response.json();
    })
    .then(result =&gt; {
    // Process the retrieved user data
    console.log(result);
    this.sendSocketNotification('MPT_RESULT', result);
  })
  .catch(error =&gt; {
    console.error('Error:', error);
  });
},


  socketNotificationReceived: function(notification, payload) {
            if (notification === 'GET_MPT') {
            this.getMPT(payload);
            }
  }
});
</code></pre>
<p dir="auto">In the console I see the data:</p>
<pre><code>[2024-06-24 21:39:44.867] [LOG]   {
  code: 200,
  status: 'OK',
  data: {
    timings: {
      Fajr: '03:08',
      Sunrise: '05:21',
      Dhuhr: '13:40',
      Asr: '18:03',
      Sunset: '21:59',
      Maghrib: '21:59',
      Isha: '00:04',
      Imsak: '02:58',
      Midnight: '01:40',
      Firstthird: '00:26',
      Lastthird: '02:54'
    },
    date: {
      readable: '24 Jun 2024',
      timestamp: '1719257984',
      hijri: [Object],
      gregorian: [Object]
    },
    meta: {
      latitude: 51.48167,
      longitude: 5.66111,
      timezone: 'Europe/Amsterdam',
      method: [Object],
      latitudeAdjustmentMethod: 'ANGLE_BASED',
      midnightMode: 'STANDARD',
      school: 'STANDARD',
      offset: [Object]
    }
  }
} 
</code></pre>
<p dir="auto">Only 1 problem, times are not displayed in de module</p>
<p dir="auto"><img src="/assets/uploads/files/1719258394265-484fd6c8-7285-4aef-ad68-9445b6a22fb2-image.png" alt="484fd6c8-7285-4aef-ad68-9445b6a22fb2-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I know it has something to do with</p>
<pre><code>var result = JSON.parse(body).data.timings;               // 
</code></pre>
<p dir="auto">but I’m having troubles with this.<br />
When I replace body with result, I get an error.<br />
I’ve been looking for a solution for a few days now, but no result.</p>
<p dir="auto">Some help is appreciated ;-)</p>
]]></description><link>https://forum.magicmirror.builders/post/118444</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118444</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Mon, 24 Jun 2024 19:49:44 GMT</pubDate></item><item><title><![CDATA[Reply to Need help for rewrite node_helper.js from &#x27;request&#x27; to &#x27;got&#x27; on Thu, 20 Jun 2024 19:37:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> just use the built in fetch</p>
<p dir="auto">no libraries needed</p>
<p dir="auto">fetch is in node 18 or above and electron 26 or above.</p>
<p dir="auto">very similar to request.</p>
<p dir="auto">look at the calendar fetcher js, which used request before.</p>
]]></description><link>https://forum.magicmirror.builders/post/118396</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/118396</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 20 Jun 2024 19:37:07 GMT</pubDate></item></channel></rss>