# How to create a msg with multi parameters

**URL:** <https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175>\
**Category:** General\
**Created:** [9 August 2019 15:41 UTC](https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175 "2019-08-09T15:41:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![316248269](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/316248269/32/10773_2.png) [@316248269](https://discourse.nodered.org/u/316248269)\
**Post date:** [9 August 2019 15:41 UTC](https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175/1 "2019-08-09T15:41:31Z")

</div>

Hi: I want to creat a new msg in function node like the msg below with multi parameters. How I should write?  
msg.payload : Object  
object  
weather: "Rain"  
temp\_maxc: 25.5  
temp\_minc: 18.3  
humidity: 53  
pressure: 1000

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 August 2019 15:53 UTC](https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175/2 "2019-08-09T15:53:41Z")

</div>

Like this?

```auto
msg.payload = {
 weather: "Rain",
 temp_maxc: 25.5,
 temp_minc: 18.3, 
 humidity: 53, 
 pressure: 1000
}
return msg;

```

To create an object in JS, its just `{}` this is quite fundamental - you would do yourself a favour to do a little online training.

  
EDIT...  
Just released you said "new msg" (however I dont recommend creating new msg every time - my preference is to re-use the msg object.

If you REALLY need a new msg then...

```auto
var newMsg = {};// create a new object
newMsg.payload = {
 weather: "Rain",
 temp_maxc: 25.5,
 temp_minc: 18.3, 
 humidity: 53, 
 pressure: 1000
}
return newMsg;

```

---

<div class="post-metadata">

**Author:** ![316248269](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/316248269/32/10773_2.png) [@316248269](https://discourse.nodered.org/u/316248269)\
**Post date:** [9 August 2019 16:13 UTC](https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175/3 "2019-08-09T16:13:33Z")

</div>

Thank u so much.  
But it seems that I asked wrong...  
The node "openweathermap" requires input `msg.location.city` and `msg.location.country`.  
This is "location" rather than "payload". I know the "location" is not a correct parameter of msg.  
How to create the msg like this..

---

<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:** [9 August 2019 16:35 UTC](https://discourse.nodered.org/t/how-to-create-a-msg-with-multi-parameters/14175/4 "2019-08-09T16:35:10Z")

</div>

Messages are regular JavaScript objects. They can have whatever properties you want them to have.

If you look at the code that @Steve-Mcl shared, he showed how to set `msg.payload` as an object of key/value pairs

So to set `msg.location` instead, you can do:

```auto
msg.location = {
   city: "here",
   country: "there"
}

```
