# Output JSON from a homeyscript

**URL:** <https://community.homey.app/t/output-json-from-a-homeyscript/91097>\
**Category:** Questions & Help\
**Tags:** homeyscript, advancedflow\
**Created:** [October 6, 2023, 8:58am UTC](https://community.homey.app/t/output-json-from-a-homeyscript/91097 "2023-10-06T08:58:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoeMama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/joemama/32/89283_2.png) [@JoeMama](https://community.homey.app/u/JoeMama)\
**Post date:** [October 6, 2023, 8:58am UTC](https://community.homey.app/t/output-json-from-a-homeyscript/91097/1 "2023-10-06T08:58:27Z")

</div>

Hey!

I am using the HTTP GET command in Honeyscript to fetch a JSON through an API.

I want to use an advanced flow to extract only a portion of the JSON file and convert it to a text tag with the «Analyze» card. This is to send a push notification, much like in the «chuck norris» example given by Homey when you open your first advanced flow.

However - I get my fetch the JSON without any errors, but I have no idea how to output the JSON through a @result tag that I can use in the «Analyze» card.

The GET HTTP flow card is unable to complete the fetch, even with the same parameters I use in the homeyscript, that’s why I’m not using the built in GET function.

So, the question is really, what bit of code should I enter in the homeyscript to make a JSON output I can use further out in my advanced flow?  
MUCH appreciated!

---

<div class="post-metadata">

**Author:** ![Techniman](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/techniman/32/8654_2.png) [@Techniman](https://community.homey.app/u/Techniman)\
**Post date:** [October 6, 2023, 8:01pm UTC](https://community.homey.app/t/output-json-from-a-homeyscript/91097/2 "2023-10-06T20:01:38Z")

</div>

Personally I try to do as much as possible in HS, this is basically the script I use the below,  
i’ve commented the file for your convenience

```auto
let key = "XXXX" ;
let loc = "51.246,5.123" ;
let url = "https://weerlive.nl/api/json-data-10min.php?key="+key+"&locatie="+loc ; 

//requesting the data
let response = await fetch(url);
//if response is not OK 
if(!response.ok) throw new Error('Failed to query');
//else process the response in the html variable
//since i'm expecting json i want it to be treated as json
let html = await response.json();
//to view the output uncomment the line below
//console.log(html)
//i'm only interested in the data shown after the "liveweer[0]" 
html = html.liveweer[0] ;
//retun that data to be used on another card 
return html ; 

```

---

<div class="post-metadata">

**Author:** ![JoeMama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/joemama/32/89283_2.png) [@JoeMama](https://community.homey.app/u/JoeMama)\
**Post date:** [October 12, 2023, 7:18am UTC](https://community.homey.app/t/output-json-from-a-homeyscript/91097/3 "2023-10-12T07:18:26Z")

</div>

Thanks so much for the comments in the code! I will try this and see how it works out.
