# Give output of a node based on a service call done in fixed time intervals

**URL:** <https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157>\
**Category:** General\
**Created:** [8 August 2018 15:09 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157 "2018-08-08T15:09:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![malinthasa](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@malinthasa](https://discourse.nodered.org/u/malinthasa)\
**Post date:** [8 August 2018 15:09 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157/1 "2018-08-08T15:09:00Z")

</div>

Hi,

I have a node which has 0 inputs and 1 output. I need to use this node as a mediator which converts and forwards the response of a rest service based on a specific parameter of the response. I have to implement this node to send requests to the REST service every 5 seconds and give output based on the response from the requested service. I do not know how to perform an action without an explicit call to a node. Up to now, I used

```
`node.on('input';function(msg){
//perform action
//then send output
}

```

which performs some action when we give an input to the node. How can we perform some action (REST service call) without 'input' event or any other explicit event? The node should start this action once it is deployed.  
How can I do this?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 August 2018 15:56 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157/2 "2018-08-08T15:56:29Z")

</div>

That is what the inject node is for. It will trigger at the interval you set it to.

---

<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:** [8 August 2018 16:07 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157/3 "2018-08-08T16:07:02Z")

</div>

Have a look at the standard JavaScript `setInterval` function. It can be used to call a function at regular intervals. You _must_ make sure you use `clearInterval` in your nodes close handler to stop calling the function after the node has been removed.

You can have a look at the feed parser node as an example : [https://github.com/node-red/node-red-nodes/tree/master/social/feedparser](https://github.com/node-red/node-red-nodes/tree/master/social/feedparser)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 August 2018 16:11 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157/4 "2018-08-08T16:11:32Z")

</div>

Ahhh right...no inputs so you can't connect an inject - ignore my suggestion. 🙄

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 August 2018 16:23 UTC](https://discourse.nodered.org/t/give-output-of-a-node-based-on-a-service-call-done-in-fixed-time-intervals/2157/5 "2018-08-08T16:23:48Z")

</div>

Surely it is a matter of choice whether it has an input.
