# Call function inside a template

**URL:** <https://discourse.nodered.org/t/call-function-inside-a-template/66008>\
**Category:** General\
**Tags:** http-request, function-node\
**Created:** [4 August 2022 10:02 UTC](https://discourse.nodered.org/t/call-function-inside-a-template/66008 "2022-08-04T10:02:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshuaC](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@joshuaC](https://discourse.nodered.org/u/joshuaC)\
**Post date:** [4 August 2022 10:02 UTC](https://discourse.nodered.org/t/call-function-inside-a-template/66008/1 "2022-08-04T10:02:47Z")

</div>

Hello,  
I have a flow that is starting with an http node (GET), checking for the login, and if successful, I have some functions and rest api call (post) that are being run to retrieve some data. After that I display my data to the user using the template node (containing html and javascript)  
what I want to achieve now is to run a new function / rest api call (or the previous function / rest api call of the flow) when a user is modifying an input on the screen.  
Is this even possible? if so how can I do it? because right now I don't see a way to call a function using the template node.  
I succeed to do something similar by refreshing the page (using some query in the url), but I would like to to that without refreshing (or changing) the page.  
Thanks!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [4 August 2022 13:47 UTC](https://discourse.nodered.org/t/call-function-inside-a-template/66008/2 "2022-08-04T13:47:39Z")

</div>

The template node itself is a simple "template" that can access msg variables, afaik it cannot do anything else.

If you are just using http-in/-out nodes to provide an endpoint, you may want to consider moving to uibuilder so that you can more easily add extra processing. uibuilder gives you a messaging interface that lets you easily send node-red messages into your front-end code and back again. It also has a (somewhat experimental) option to turn on server-side EJS templating which might also help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 August 2022 13:47 UTC](https://discourse.nodered.org/t/call-function-inside-a-template/66008/3 "2022-08-18T13:47:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
