# RED.httpAdmin.get not refreshing JSON

**URL:** <https://discourse.nodered.org/t/red-httpadmin-get-not-refreshing-json/7113>\
**Category:** Developing Nodes\
**Created:** [21 January 2019 20:19 UTC](https://discourse.nodered.org/t/red-httpadmin-get-not-refreshing-json/7113 "2019-01-21T20:19:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![germancmartinez](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@germancmartinez](https://discourse.nodered.org/u/germancmartinez)\
**Post date:** [21 January 2019 20:19 UTC](https://discourse.nodered.org/t/red-httpadmin-get-not-refreshing-json/7113/1 "2019-01-21T20:19:56Z")

</div>

Hi,

I´m using httpAdmin.get to send a json from the runtime js to the html. The problem I have is that the json is only updated the first time the code runs. I can see in the console that data variable is being updated, but when I see the json (opening the url with Chrome), the information is not being updated. It is refreshed only the first time after restarting Node-Red.  
I think that maybe the res.json() is not able to over-write the existing json, but I don't know what to use instead.  
Can anyone please help me?

**mycostumnode.js:**

```auto
node.updateEquipmentList = setInterval( async function () {
            var data={};
            if (typeof node.server !== 'undefined' && node.server && typeof node.server.getEquipmentsModel === 'function'){
                data = await node.server.getEquipmentsModel();
                RED.httpAdmin.get("/equipments/:id", RED.auth.needsPermission('TimeSeries.read'), function(req,res) {
                    res.json(data);
                });
                console.log(JSON.stringify(data));
            }
        }, 10000);

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [21 January 2019 20:37 UTC](https://discourse.nodered.org/t/red-httpadmin-get-not-refreshing-json/7113/2 "2019-01-21T20:37:52Z")

</div>

Hi @germancmartinez - when sharing code on the forum _please_ follow the advice in this post: [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506). I have edited your post to fix the formatting.

You are creating an interval that runs every 10 seconds to update some data. The problem comes that you add a new route handler to `RED.httpAdmin` every time. That is not a good idea. You should separate those things out:

- add _one_ route handler that returns whatever is currently in `data`
- create an interval to update `data` as needed

```auto

var data = {};
RED.httpAdmin.get("/equipments/:id", RED.auth.needsPermission('TimeSeries.read'), function(req,res) {
   res.json(data);
});

node.updateEquipmentList = setInterval( async function () {
    var data={};
    if (typeof node.server !== 'undefined' && node.server && typeof node.server.getEquipmentsModel === 'function'){
      data = await node.server.getEquipmentsModel();
      console.log(JSON.stringify(data));
    }
}, 10000);

```

Finally, make sure you clear the `node.updateEquipmentList` interval in your node's close handler.

---

<div class="post-metadata">

**Author:** ![germancmartinez](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@germancmartinez](https://discourse.nodered.org/u/germancmartinez)\
**Post date:** [22 January 2019 02:09 UTC](https://discourse.nodered.org/t/red-httpadmin-get-not-refreshing-json/7113/3 "2019-01-22T02:09:00Z")

</div>

Thank you so much! Now it's working!
