Can't view items

This is my code its can log the value but can’t view Items

<App>
    <DockPanel>
        <JavaScript> 
        var Observable = require("FuseJS/Observable");
        var status = 0;
        var getData = Observable();
        var getUser = Observable("asd");
        fetch('***', {
            method: 'POST',
            headers: { "Content-type": "application/json"},
            body: JSON.stringify({})
        }).then(function(response) {
            return response.json();    // This returns a promise
        }).then(function(responseObject) {
            getData = Observable(responseObject.d.item.list).value;
            console.log(getData[6].name);
        }).catch(function(err) {
            console.log(err);
        });
        
        module.exports = {
			getData:getData,
            getUser:getUser
		};
        </JavaScript>

<StatusBarBackground DockPanel.Dock="Top"/>
        <ScrollView>
            <StackPanel>
                <Each Items="{getData}">
                    <Text Value="{name}"/>
                </Each>
            </StackPanel>
        </ScrollView>

    </DockPanel>
</App>

Hi hindux

I think the problem is that your getData variable is not an observable when you set it to Observable(responseObject.d.item.list).value. The .value pulls the plain value (without the reactive components) and hence the getData variable becomes non-reactive. Also, when the response is an array (which I assume) you have to use replaceAll to put it into an observable. Try to use

getData.replaceAll(responseObject.d.item.list)

Best regards

Morten

1 Like