# Sending slider value inside template

**URL:** https://discourse.nodered.org/t/sending-slider-value-inside-template/34314
**Category:** General
**Created:** [15 October 2020 18:13 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314 "2020-10-15T18:13:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nezoo](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@nezoo](https://discourse.nodered.org/u/nezoo)
#### Post date: [15 October 2020 18:13 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/1 "2020-10-15T18:13:29Z")

</div>

Is it possible to send a variable in response to get request ????

```auto
[{"id":"1c7fe071.dd4f98","type":"tab","label":"api sim","disabled":false,"info":""},{"id":"42d886d.2fab478","type":"http in","z":"1c7fe071.dd4f98","name":"","url":"hello","method":"get","upload":false,"swaggerDoc":"","x":310,"y":280,"wires":[["b67cda5d.60cae"]]},{"id":"b67cda5d.60cae","type":"template","z":"1c7fe071.dd4f98","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\"payload\":50}","output":"str","x":610,"y":300,"wires":[["1c83adb8.a01502"]]},{"id":"1c83adb8.a01502","type":"http response","z":"1c7fe071.dd4f98","name":"","statusCode":"","headers":{},"x":1040,"y":300,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [15 October 2020 19:35 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/2 "2020-10-15T19:35:09Z")

</div>

If i understand your query, yes

e.g.

```auto
[{"id":"bc6aee81.3a1f3","type":"http in","z":"6fcc3140.459a2","name":"","url":"hello","method":"get","upload":false,"swaggerDoc":"","x":270,"y":240,"wires":[["8953ca4f.f212a"]]},{"id":"90279a5b.bfc3a8","type":"ui_slider","z":"6fcc3140.459a2","name":"slider","label":"slider","tooltip":"","group":"165e1e1a.e752fa","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":"5","x":380,"y":320,"wires":[["fbf435a6.35b9e8"]]},{"id":"8953ca4f.f212a","type":"change","z":"6fcc3140.459a2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"slider","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["b0b64c93.b81398"]]},{"id":"fbf435a6.35b9e8","type":"change","z":"6fcc3140.459a2","name":"","rules":[{"t":"set","p":"slider","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":320,"wires":[["9dc7ea0f.e862b8"]]},{"id":"b0b64c93.b81398","type":"http response","z":"6fcc3140.459a2","name":"","statusCode":"","headers":{},"x":710,"y":240,"wires":[]},{"id":"9dc7ea0f.e862b8","type":"debug","z":"6fcc3140.459a2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":320,"wires":[]},{"id":"e3fc91f5.c1d078","type":"inject","z":"6fcc3140.459a2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":250,"y":320,"wires":[["90279a5b.bfc3a8"]]},{"id":"165e1e1a.e752fa","type":"ui_group","z":"","name":"Default","tab":"f9b58883.fa613","order":1,"disp":true,"width":"12","collapse":false},{"id":"f9b58883.fa613","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![nezoo](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@nezoo](https://discourse.nodered.org/u/nezoo)
#### Post date: [15 October 2020 22:52 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/3 "2020-10-15T22:52:36Z")

</div>

thanks alot dude you made my day . i was trying to deserialize Json response in ESP32 and getting the value of slider as long received in esp32 , i made some changes her is the prototype:

```auto
[{"id":"88b25812.a52fd8","type":"http in","z":"c043cf8e.9fbab","name":"","url":"hello","method":"get","upload":false,"swaggerDoc":"","x":540,"y":480,"wires":[["6548ad5d.850b5c"]]},{"id":"fd29bab0.a3fe38","type":"ui_slider","z":"c043cf8e.9fbab","name":"slider","label":"slider","tooltip":"","group":"4abde384.aad474","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"1000","step":"5","x":650,"y":560,"wires":[["3d324a4b.c8ee66"]]},{"id":"6548ad5d.850b5c","type":"change","z":"c043cf8e.9fbab","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"slider","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":480,"wires":[["815ecbfa.09d6c"]]},{"id":"3d324a4b.c8ee66","type":"change","z":"c043cf8e.9fbab","name":"","rules":[{"t":"set","p":"slider","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":560,"wires":[["e1622ee.a96b5d"]]},{"id":"a97be0e1.78358","type":"http response","z":"c043cf8e.9fbab","name":"","statusCode":"","headers":{},"x":1190,"y":480,"wires":[]},{"id":"e1622ee.a96b5d","type":"debug","z":"c043cf8e.9fbab","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1040,"y":560,"wires":[]},{"id":"126cf64f.d1b3ca","type":"inject","z":"c043cf8e.9fbab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":520,"y":560,"wires":[["fd29bab0.a3fe38"]]},{"id":"815ecbfa.09d6c","type":"json","z":"c043cf8e.9fbab","name":"","property":"payload","action":"str","pretty":false,"x":960,"y":400,"wires":[["a97be0e1.78358","8f8a6a13.1fd968"]]},{"id":"8f8a6a13.1fd968","type":"debug","z":"c043cf8e.9fbab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1340,"y":300,"wires":[]},{"id":"4abde384.aad474","type":"ui_group","z":"","name":"SENSORS","tab":"2b8559ab.f8b276","order":1,"disp":true,"width":"6","collapse":false},{"id":"2b8559ab.f8b276","type":"ui_tab","z":"","name":"HTTP","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![nezoo](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@nezoo](https://discourse.nodered.org/u/nezoo)
#### Post date: [15 October 2020 23:00 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/4 "2020-10-15T23:00:10Z")

</div>

here is a photo from the the flow , i am trying in this project to exchange data between node red and ESP32 through GET/POST requests every 1 second and i will try to send data packet between both . i didn't like MQTT very much i find HTTP more flexible . does anyone have any idea why such a concept isn't common do i miss something ???? is there anyway also to send the variable value inside JSON object like this {"val" : payload } ??? i could send the response just by converting the payload to JSON

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/093d868375ca9f5abd9537cc4072021782835459.jpeg)

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [16 October 2020 06:49 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/5 "2020-10-16T06:49:51Z")

</div>

```auto
[{"id":"232bf664.c42c4a","type":"http in","z":"6fcc3140.459a2","name":"","url":"hello","method":"get","upload":false,"swaggerDoc":"","x":90,"y":580,"wires":[["5ef3947b.cea06c"]]},{"id":"5ef3947b.cea06c","type":"change","z":"6fcc3140.459a2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"slider\":$flowContext('slider')}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":580,"wires":[["c7c1897c.129798","121c5c2c.a20bbc"]]},{"id":"c7c1897c.129798","type":"debug","z":"6fcc3140.459a2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":400,"wires":[]},{"id":"121c5c2c.a20bbc","type":"http response","z":"6fcc3140.459a2","name":"","statusCode":"","headers":{},"x":740,"y":580,"wires":[]}]

```

you can create the object in the change node.

---

<div class="post-metadata">

### Author: ![nezoo](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@nezoo](https://discourse.nodered.org/u/nezoo)
#### Post date: [16 October 2020 12:19 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/6 "2020-10-16T12:19:17Z")

</div>

thanks again , your help was tremendous .it is even faster now maybe because i was fetching the whole document before  
`doc.as<long>();`

but now i am fetching the JSON object like this : `doc["slider"].as<long>());`  
in which section in node red documentation is this way of accessing a value like `{"slider":$flowContext('slider')}` explained ????

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [16 October 2020 12:22 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/7 "2020-10-16T12:22:02Z")

</div>

It is explain in the JSONata site as the change node can use JSONata expressions

> **[JSONata Documentation · JSONata](https://docs.jsonata.org/overview.html)**
>
> \## Introduction

> [@nezoo](#):
>
> `{"slider":$flowContext('slider')}`

this is a text literal representation of a object, The $flowContext() is retrieving the value from context store.

---

<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: [30 October 2020 12:22 UTC](https://discourse.nodered.org/t/sending-slider-value-inside-template/34314/8 "2020-10-30T12:22:03Z")

</div>

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