# Now to get node values from json fetch

**URL:** <https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992>\
**Category:** How-to Discussions\
**Created:** [December 23, 2015, 4:55am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992 "2015-12-23T04:55:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 23, 2015, 4:55am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/1 "2015-12-23T04:55:44Z")

</div>

Team i need your help to get individual node values from a json fetch. I need this in order to run functions depeding on the value of each node.

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 23, 2015, 8:27am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/2 "2015-12-23T08:27:53Z")

</div>

What have you tried?

Did you look at the News feed example? [https://www.fusetools.com/examples/news-feed](https://www.fusetools.com/examples/news-feed)

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 23, 2015, 1:12pm UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/3 "2015-12-23T13:12:30Z")

</div>

Yes i tried and succeded pulling the data and displaying the data using each. But what i need is to get an specific node value.

Example my json file is

[{“Name”:“Marco”,“Seconds”:123,“Other”:4},{“Name”:“David”,“Seconds”:45,“Other”:3}] And i want to assign the value of of seconds node 1 to a variable then using a function convert seconds to h:mm:ss. And i also want to pass the variable to a conditional expression. (if Other is == then)

My issue is geting node values then assign then to a observable variable to do magic

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 23, 2015, 1:44pm UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/4 "2015-12-23T13:44:38Z")

</div>

This is normal JavaScript programming. `var seconds = json[0].Seconds;`

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 23, 2015, 2:10pm UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/5 "2015-12-23T14:10:26Z")

</div>

Thanks i was writing the expression inverse. LOL

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 24, 2015, 1:35am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/6 "2015-12-24T01:35:23Z")

</div>

:S i just got home and im still having and error.undefined cannot be converted to an object. I paste the code in a min. Thanks

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 24, 2015, 1:41am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/7 "2015-12-24T01:41:27Z")

</div>

Help please im a noob, ErrorMessage: undefined cannot be converted to an object

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

        var callstats = Observable();
        var test1 = Observable();

        fetch('http://localhost/marmarti/json/calls.json&#39;)
        .then(function(result) { 
            result.json().then(function(data) {
                    debug_log("Success");
                    for (var i = 0; i<data.length; i++) {
                        var item = data[i];
                        callstats.add(item);

                    }
                });
             });

        test1 = callstats[1].EnterpriseName;

        module.exports = {
            testos: callstats,
            test1: test1
        };

    </JavaScript>

```

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 24, 2015, 5:15am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/8 "2015-12-24T05:15:29Z")

</div>

Found the solution using case function 🙂

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 24, 2015, 11:13am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/9 "2015-12-24T11:13:16Z")

</div>

Good. If you need more help, please post the JSON as well. 🙂

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 26, 2015, 3:46pm UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/10 "2015-12-26T15:46:32Z")

</div>

Bjørn-Olav Strand, I still need help (T\_T) . I didnt acheive the results i was looking for, using each match and case. I would like to get the node values from javascript like and assign that to an Observable variable:

eng.value = callstats[0].RouterCallsQNow + callstats[8].RouterCallsQNow;

Below my Json and JavaScript files thanks in advance.

Json File

```auto
[{"EnterpriseName":"ENGLISH_OPC1","RouterCallsQNow":20,"DATES":0},{"EnterpriseName":"FRENCH_FRA","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"FRENCH_CAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"PORTUGUES_POR","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"PORTUGUES_BRA","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"ITALIAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"GERMAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"SPANISH","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"ENGLISH_OPC2","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"OPT7","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"OPC3","RouterCallsQNow":0,"DATES":0}]

```

And JavaScript

```auto
<App Theme="Basic" ClearColor="#eeeeeeff">
        <JavaScript> var Observable = require("FuseJS/Observable");

            var callstats = Observable();

var myVar = setInterval(loadall, 1000);

function loadall() {
load_calls_queue();
}

function load_calls_queue (){
    callstats.clear();
    var myRequest = new Request('http://localhost/marmarti/json/calls.json&#39;);

            fetch(myRequest)
            .then(function(response) { 
                return response.json().then(function(data) {
                        debug_log("Success");
                        for (var i = 0; i<data.length; i++) {
                            var item = data[i];
                            callstats.add(item);
                        }
                    });
                });
            }

            module.exports = {
                testos: callstats
            };
        </JavaScript>

```

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 26, 2015, 6:53pm UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/11 "2015-12-26T18:53:04Z")

</div>

To access Observables use `getAt`

`eng.value = callstats.getAt(0).RouterCallsQNow + callstats.getAt(8).RouterCallsQNow;`

---

<div class="post-metadata">

**Author:** ![markwinap](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markwinap/32/382_2.png) [@markwinap](https://forums.fusetools.com/u/markwinap)\
**Post date:** [December 27, 2015, 2:44am UTC](https://forums.fusetools.com/t/now-to-get-node-values-from-json-fetch/3992/12 "2015-12-27T02:44:45Z")

</div>

Wow thanks a lot i feel like anakin skywalker. its workig… Its working!!!
