# How to pass method parameter into msg.payload

**URL:** https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862
**Category:** General
**Created:** [19 May 2022 18:31 UTC](https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862 "2022-05-19T18:31:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![NeetaJ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/neetaj/32/60934_2.png) [@NeetaJ](https://discourse.nodered.org/u/NeetaJ)
#### Post date: [19 May 2022 18:31 UTC](https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862/1 "2022-05-19T18:31:51Z")

</div>

```auto
[{"id":"8b4876ad871c51f5","type":"http in","z":"e97abacb4c80db24","name":"","url":"/myview","method":"get","upload":false,"swaggerDoc":"","x":250,"y":140,"wires":[["cb80d322be19fc9c"]]},{"id":"cb80d322be19fc9c","type":"template","z":"e97abacb4c80db24","name":"input form","field":"form","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<bc-section title=\"Customise my view\" id=\"home-section\" has_grid=\"false\">\n \n<form>\n<div class=\"form-group\">\n <div class=\"column--xs-12 column--md-3\" style=\"display: table;\">\n <bc-input type=\"text\" label=\"Enter the menu items\" v-model=\"form.title\" placeholder=\"\" >\n </bc-input>\n <div class=\"input-group-btn\">\n <div class=\"btn-toolbar\" v-if=\"!formiphelp\">\n <bc-button @click=\"addEntry()\" icon=\"plus\" action=\"success\" v-model=\"form.addentry\" :is_enabled=\"formiphelp=null\"></bc-button>\n </div>\n </div>\n </div>\n</div>\n\n<div class=\"table-responsive scrollbars\" v-if=\"form.items.length>0\">\n <table class=\"table table-hover\">\n <thead>\n <tr>\n <th>Entries</th>\n <th>Delete</th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"entry in form.items\">\n <td>\n {%entry%}\n </td>\n <td>\n <bc-button @click=\"deleteEntry(entry)\" icon=\"minus\" action=\"success\"></bc-button>\n </td>\n \n </tr>\n </tbody>\n </table>\n </div>\n <div class=\"btn-link-toolbar\" v-if=\"form.items.length>0\">\n <bc-button id=\"button\" @click=\"updateMyView()\" action=\"primary\" label=\"Submit\"\n ></bc-button>\n \n </div>\n</form>\n\n</bc-section>\n\n \n\n\n","output":"str","x":420,"y":140,"wires":[["bd97c05ea70ad3ec"]],"icon":"node-red/file.svg"},{"id":"bd97c05ea70ad3ec","type":"template","z":"e97abacb4c80db24","name":"javascript - vue.js","field":"vue","fieldType":"msg","format":"javascript","syntax":"mustache","template":"\nvar app = new Vue({\n\n el: '#app',\n delimiters: ['{%', '%}'],\n data: {\n user: \"{{{req.headers.x-insight-username}}}\",\n \n form: {\n items:[],\n title:[]\n \n },\n },\n\n mounted() {\n\n },\n\n created() {\n\n },\n watch: {\n \n\n },\n filters: {\n \n \n \n },\n computed: {\n\n \n },\n\n methods: {\n addEntry(){\n this.form.items.push(this.form.title)\n console.log(\"add entry\", this.form);\n this.form.title=\"\"\n },\n deleteEntry(entry) {\n console.log(\"delete address\", entry);\n this.form.items = this.form.items.filter(e => e !== entry)\n console.log(\"remaining entries\", this.form.items);\n\n },\n updateMyView(){\n var obj = { \n payload:{\n \"menuitem\":this.form.items\n }\n \n };\n console.log(\"updateMyView\", obj);\n }\n }\n\n});","x":510,"y":200,"wires":[["0b8b22b2f12c1c4e"]],"icon":"node-red/parser-json.svg"},{"id":"0b8b22b2f12c1c4e","type":"change","z":"e97abacb4c80db24","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"vue","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":280,"wires":[["9a77e5bed91f61fe"]]},{"id":"9a77e5bed91f61fe","type":"debug","z":"e97abacb4c80db24","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":280,"wires":[]}]

```

Is there any way i could access highlighted variables in msg.payload.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f65cf7b021860be39bf9fec3eec037ffa0273fe3.png)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [19 May 2022 20:58 UTC](https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862/2 "2022-05-19T20:58:30Z")

</div>

(It may be easier if you actually pasted the message here.)

Don't forget to _format_ it correctly. (3 x tilde key presses, then enter. Paste the message. Enter and lastly 3 x tilde key presses.)

When you do it you will see it look something like this:

```auto
your
message
here

```

(Ignore the blue `your`. Don't know why that happened)

---

<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: [19 May 2022 22:01 UTC](https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862/3 "2022-05-19T22:01:29Z")

</div>

Your image does not reflect your flow. It looks like you have changed the debug node in the flow you provided.

Given that, sure you can access the text by accessing msg.payload or after the `change` node, you can use msg.payload.

However in each case it is a string that you will have to parse to get to it.

Note: it is not code that is being executed

What is your goal?

---

<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 July 2022 22:01 UTC](https://discourse.nodered.org/t/how-to-pass-method-parameter-into-msg-payload/62862/4 "2022-07-18T22:01:35Z")

</div>

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