# Reading message object in js file

**URL:** https://discourse.nodered.org/t/reading-message-object-in-js-file/23867
**Category:** Developing Nodes
**Created:** [30 March 2020 03:14 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867 "2020-03-30T03:14:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)
#### Post date: [30 March 2020 03:14 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/1 "2020-03-30T03:14:13Z")

</div>

Okay so maybe this is a dumb question, but how to read, for example, msg.topic in .js file, for ( i want to log msg.topic to console)?

Done a lot of search on this, and trying reading from some other nodes, but I am a little confused.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [30 March 2020 05:46 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/2 "2020-03-30T05:46:31Z")

</div>

> but how to read, for example, msg.topic in .js file,

Could you elaborate on what you mean here ?

---

<div class="post-metadata">

### Author: ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)
#### Post date: [30 March 2020 05:51 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/3 "2020-03-30T05:51:21Z")

</div>

Well in my custom node i want to use msg.topic from input (string (ip or domain )) and save it to var address.

---

<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: [30 March 2020 07:55 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/4 "2020-03-30T07:55:15Z")

</div>

If you look at the lower-case.js example in the node red docs [creating your first node](https://nodered.org/docs/creating-nodes/first-node) it shows how to access `msg.payload`. `msg.topic` can be accessed in exactly the same way.

---

<div class="post-metadata">

### Author: ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)
#### Post date: [30 March 2020 10:43 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/5 "2020-03-30T10:43:55Z")

</div>

Thank you!

---

<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: [29 May 2020 10:43 UTC](https://discourse.nodered.org/t/reading-message-object-in-js-file/23867/6 "2020-05-29T10:43:55Z")

</div>

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