# Card HomeyScript run code fails

**URL:** <https://community.homey.app/t/card-homeyscript-run-code-fails/94738>\
**Category:** Flows\
**Tags:** homeyscript, homey-pro\
**Created:** [November 15, 2023, 6:38pm UTC](https://community.homey.app/t/card-homeyscript-run-code-fails/94738 "2023-11-15T18:38:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nine/32/82555_2.png) [@Nine](https://community.homey.app/u/Nine)\
**Post date:** [November 15, 2023, 6:38pm UTC](https://community.homey.app/t/card-homeyscript-run-code-fails/94738/1 "2023-11-15T18:38:01Z")

</div>

I have some code in order to recognize if a myStrom-Switch has a load \< 2 W:

```auto
async function checkPowerGreaterThanOne() {
  var requestOptions = {
    method: 'GET',
    redirect: 'follow'
  };

  try {
    const response = await fetch("http://172.16.1.50/report", requestOptions);
    const result = await response.json();

    // Check if "power" is less than 2.0
    if (result.power < 2.0) {
      console.log("Power is less than 2.0: " + result.power);
      return true;
    } else {
      console.log("Power is greater than 2.0: " + result.power);
      return false;
    }
  } catch (error) {
    console.log('error', error);
    throw error;
  }
}

// Call the function and handle the asynchronous response if needed
checkPowerGreaterThanOne()
  .then(result => {
    // Use the result here
    console.log("Result:", result);
  })
  .catch(error => {
    // Handle errors if necessary
    console.error("Error:", error);
  });

```

This code runs correct and returns true or false. But when I run the code in the flow-card, always the “no” output is selected – can anybody help me?
