I’m trying to make a simple script for Homey to check if it still has wifi connection. I do this by checking if it can reach the router. For this I use Fetch.
Now I want to cut back on the default timeout time and implement an error handler. (If not reachable) But I seem to be unable to create an instance of AbortController()as per the docs.. Is there way to achieve this? Is there a better way? Or is this not implemented in HS?
Hm no
The other post is about a bug in the Homey Script editor.
This is a post about how to set a custom timeout on fetch. The Homey docs say fetch is a shortcut to node-fetch.
And node-fetch says you can set/handle a fetch timeout with AbortController(). But as the docs state, you have to import it. But since your cannot import anything in HS I’m looking for a way to add AbortController() OR find an alternative to setting a custom timeout. Default is 120 sec I believe.
I’ve tried to do it with HS, because in my head it would be a quick solution. Guess I have to learn to stop comparing Homey Script to Javascript, since it’s a very closed ecosystem.
I’ll add a global var for a counter to stop rebooting after 3 times to prevent an infinite loop if something else is happening. Like for the router to run an update or whatever.