To get the JSON file of the moon data it seem to me that it cant by the Logic Get card.
What I found was a .js script but there are some difficulties for Homey-script.
1 const fetchMoonPhaseData = async () => {
2 try {
3 const response = await fetch("https://moon-phase.p.rapidapi.com/advanced", {
4 "method": "GET",
5 "headers": {
6 "x-rapidapi-host": "moon-phase.p.rapidapi.com",
7 "x-rapidapi-key": "xxxxxxxxx"
8 }
9 });
10
11 if (!response.ok) {
12 throw new Error(`HTTP error ${response.status}`);
13 }
14
15 const data = await response.json();
16 displayMoonPhase(data.phase_name);
17 } catch (error) {
18 console.error("Error fetching data:", error);
19 displayMoonPhase("Error fetching moon phase data");
20 }
21 };
22
23 const displayMoonPhase = (text) => {
24 const phaseTextElement = document.getElementById("phase-text");
25 phaseTextElement.innerText = text;
26 };
27
28 fetchMoonPhaseData();
29
30 // await tag('Moon data' , ?);
Line 30 is put by me for later getting the data out but how I don’t no jet.
The line numbers I put here myself so the lining is not correct.
In lines 1 and 23 the 1st error: =>. Changed in =>
Then the “;” in between the “=>” and “{” gives the next error.
Delete that “,” like a normal reaction but I’m tricky about it and don’t want to make problems on the api provider.
Further if some one can make it still working with the Logic Get card I prefer that.