I tried several ways to launch a script from another one
I’m note sure that my way is the best one
try {
const url = \`http://127.0.0.1/api/app/com.athom.homeyscript/script/${encodeURIComponent(SCRIPT_ID)}/run\`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': \`Bearer ${API_KEY}\`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ args: \[payload\] })
});
if (response.status === 401) {
console.error("Clé API refusée (401). Vérifier API_KEY .");
return;
}
const data = await response.json();
console.log(\`Réponse : OK\`);
} catch (e) {
console.error(\`Erreur : ${e.message}\`);
}