let groupname = context.panel.elements.find(e => e.id === "groupname")?.value; async function ejecutarPeticion() { async function getToken() { let token = null; const res = await fetch("http://localhost:8080/api_jsonrpc.php", { method: "GET", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", method: "user.login", params: { username: "Admin", password: "zabbix" }, id: 1 }) }); const data = await res.json(); token = data.result; return token; } let token = await getToken(); let groupRes = await fetch("http://localhost:8080/api_jsonrpc.php", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + token }, body: JSON.stringify({ jsonrpc: "2.0", method: "hostgroup.get", params: { output: "extend", filter: { name: "" + groupName } }, id: 2 }) }); return petition; } return ejecutarPeticion();