Wordpress Json each not working

Not getting value in ux while uisng below code.

       var Observable = require("FuseJS/Observable");

       var data = Observable();

        fetch('http://dev.julienrenaux.fr/wp-json/wp/v2/posts')
        .then(function(response) { return response.json(); })
        .then(function(responseObject) { data.value = responseObject;});

        module.exports = {
            data: data,

        };

        ux//
        <Each Items="{data}">
                    <NewsItem />
                </Each>
                ```

but when i change responseObject to

                .then(function(responseObject) { data.value = responseObject[0];});

iam getting the first object and its items and values.

  1. I am also facing the same problem here… getting a first value only and also …

  2. I am wondering how to render a html tags/attributes inside fuse…

For example: wp-restapi having a value like

file

how do i show the rendered paragrapgh content inside fuse. (Getting content along with “p” tag)

anishtr4@gmail.com: When you assign directly to data.value, your observable gets one item, and that item is the list of posts. What you want to do is make sure the observable itself has the list of posts:

         .then(function(responseObject) {
             responseObject.forEach(function(item){
                 data.add(item);
             })
         });

Full example:

<App>
    <JavaScript>
        var Observable = require("FuseJS/Observable");

        var data = Observable();

         fetch('http://dev.julienrenaux.fr/wp-json/wp/v2/posts&#39;)
         .then(function(response) { return response.json(); })
         .then(function(responseObject) {
             responseObject.forEach(function(item){
                 data.add(item);
             })
         });

         module.exports = {
             data: data,

         };
    </JavaScript>
    <StackPanel>
        <Each Items="{data}">
            <Text Value="{id}"/>
        </Each>
    </StackPanel>
</App>

ramkrishnaramkiran@gmail.com : Fuse currently doesn’t have a good solution for rich text. We’re working on it, but I can’t promise you a specific release date.

In the mean time, you might be better off displaying the posts in a WebView.

I have a same problem.

James Arthur:

When your request returns an array of data, you have to fill the Observable with each item from the array. Anders’ solution above works, but the quickest way is to use yourObservable.replaceAll(responseData)