@sdetweil
;-)
Read the statement by Michael Teeuw here.

Posts
-
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil
Sam, you put a comment in node_helper.js.
I don’t understand what you mean.// don’t need this anymore with async below
-
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil
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.I’ll let you know!!
-
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil published it. Didn’t know how than on Master.
-
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil
In the previous version with ‘request’ I used JSON.parse() and got the same results.
The module works, but I didn’t know for sure if I used the correct approach. -
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil
That I don’t understand.
Is this a problem? What would be better? -
RE: Need help for rewrite node_helper.js from 'request' to 'got'
@sdetweil
As far as I can see this works the correct way.
Do you agree? -
RE: Need help for rewrite node_helper.js from 'request' to 'got'
I kept on searching and think I’ve found it.
I didn’t use JSON.parse(), but simply put it in the resultthis.sendSocketNotification('MPT_RESULT', result.data.timings);
It works, but I hope this is the right way.
-
RE: Need help for rewrite node_helper.js from 'request' to 'got'
Oké, made a start.
Changed my node_helper.js to:/* //------------------------------------------- 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 => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(result => { // Process the retrieved user data console.log(result); this.sendSocketNotification('MPT_RESULT', result); }) .catch(error => { console.error('Error:', error); }); }, socketNotificationReceived: function(notification, payload) { if (notification === 'GET_MPT') { this.getMPT(payload); } } });
In the console I see the data:
[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] } } }
Only 1 problem, times are not displayed in de module
I know it has something to do with
var result = JSON.parse(body).data.timings; //
but I’m having troubles with this.
When I replace body with result, I get an error.
I’ve been looking for a solution for a few days now, but no result.Some help is appreciated ;-)
-
Need help for rewrite node_helper.js from 'request' to 'got'
As we all know, the Nodejs module “request” is deprecated.
I like to rewrite my node_helper.js module so request is not used anymore. Instead the Nodejs module “got” will be used.Module: https://github.com/htilburgs/MMM-MyPrayerTimes
Can someone help me on my way?
I’m not a developer and just do it for fun.