# Type error in function node

**URL:** <https://discourse.nodered.org/t/type-error-in-function-node/38004>\
**Category:** Developing Nodes\
**Created:** [25 December 2020 10:45 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004 "2020-12-25T10:45:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fpravin22](https://avatars.discourse-cdn.com/v4/letter/f/e274bd/32.png) [@fpravin22](https://discourse.nodered.org/u/fpravin22)\
**Post date:** [25 December 2020 10:45 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004/1 "2020-12-25T10:45:09Z")

</div>

typeError: msg.payload.replace is not a function

---

<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:** [25 December 2020 10:48 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004/2 "2020-12-25T10:48:39Z")

</div>

Hi @fpravin22 welcome to the forum,

Can you provide more details of the error you are hitting?

What does msg.payload contain? `replace` is a function only available on String types. This error suggests you are trying to use it on a different type of object. You can use the Debug node to see exactly what your message contains.

---

<div class="post-metadata">

**Author:** ![fpravin22](https://avatars.discourse-cdn.com/v4/letter/f/e274bd/32.png) [@fpravin22](https://discourse.nodered.org/u/fpravin22)\
**Post date:** [25 December 2020 11:43 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004/3 "2020-12-25T11:43:07Z")

</div>

I want to read data from input so i take function node and write function as:  
msg.payload = msg.payload.replace("temp=", "").replace("'c", "");  
then error is occured

---

<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:** [25 December 2020 12:08 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004/4 "2020-12-25T12:08:45Z")

</div>

Put a debug node before the function, show us what is in the payload. (expand and objects properties)

Also, might be worth spending 10 mins reading this...

> **[Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)**

---

<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:** [23 February 2021 12:08 UTC](https://discourse.nodered.org/t/type-error-in-function-node/38004/5 "2021-02-23T12:08:45Z")

</div>

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