Display json from remote

Hello,

I have followind json structure from remote :

  {
    "post_id": 68,
    "post_title": "Lundi",
    "content": "<strong>LUNDI</strong>\r\n\r\n10h00 - 12h30\r\n\r\n&nbsp;",
    "img": "http://www.mydomain.com/im_programme.jpg&quot;,
    "extrait": "<strong>LUNDI</strong>\r\n\r\n10h00 - 12h30\r\n\r\n&nbsp;",
    "post_url": "http://www.mydomain.com/?semaine=lundi&quot;,
    "ipad": "<h4>10h00 - 12h30</h4>\r\n&nbsp;"
  }, ... etc

My code to fetch :

...
<JavaScript>
fetch('http://www.mydomain.com/xxx/?get=videos&#39;)
    .then(function(response) { return response.json(); })
    .then(function(responseObject) { 
        console.log(JSON.stringify(responseObject)) // JSON successfully received
        data.value = responseObject;

});

module.exports = {data: data};
</JavaScript>
<Each Items="{data}">
    <Grid ColumnCount="2">
        <Text Value="{post_id}" />
        <Text Value="{post_title}" />
    </Grid>
</Each>
  ...

When i preview, nothings displayed to the simulator, what i have done wrong? the console.log diplays the retrieved json on the monitor but i don’t know how to loop on fuse.

Thank you for help, i am about to experiment some ui also, i will post here results soon

Hi,

Try this:

data.replaceAll(responseObject);

This assumes responseObject is an array.

Hello thank you, so i have to convert the json object to array? the ‘replaceAll’ is a javascript native method? i haven’t found a doc about this on google.

Hi,

How to do this depends on the structure of the JSON returned from the server. The above code assumes the JSON contains an array at the root level.

You can find docs for the members of Observable here:

https://www.fusetools.com/learn/fusejs#observable-replaceall-replaceall-array

cool, thanks again for your responses.