# Function Node: "TypeError: msg.payload.replaceAll is not a function"

**URL:** <https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288>\
**Category:** General\
**Created:** [8 January 2022 10:02 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288 "2022-01-08T10:02:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob22](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jacob22](https://discourse.nodered.org/u/jacob22)\
**Post date:** [8 January 2022 10:02 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/1 "2022-01-08T10:02:22Z")

</div>

Hey guys!  
I am measuring data from the RasPi with an Exec Node. This measurements come as a string with an endline at the end. I used to have a function node wich replaces the \n. I don't know what i have changed but now i get the following debug-message: "TypeError: msg.payload.replaceAll is not a function"  
I want to have it in "float" format, not "string"

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4f9cd416bd93d139b96df6247b2c4bfa619d0f6.png)

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c12de21469d8909f4c31b8e02bae894be3493d1b.png)

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/ccd0c00409bf90000a2d6cb9ea9f11f7692ee21c.png)

Regards,  
Jacob

---

<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:** [8 January 2022 10:46 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/2 "2022-01-08T10:46:04Z")

</div>

ReplaceAll [requires nodejs v15 or greater](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#browser_compatibility). What version of node are you running?

---

<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:** [8 January 2022 10:46 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/3 "2022-01-08T10:46:58Z")

</div>

Try `msg.payload.trim()` it should remove any white space, including newline.

---

<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:** [8 January 2022 10:47 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/4 "2022-01-08T10:47:17Z")

</div>

Ps, parseFloat will ignore the carriage return and will just work (iirc)

---

<div class="post-metadata">

**Author:** ![jacob22](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jacob22](https://discourse.nodered.org/u/jacob22)\
**Post date:** [8 January 2022 10:52 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/5 "2022-01-08T10:52:08Z")

</div>

thanks, works just fine!

---

<div class="post-metadata">

**Author:** ![jacob22](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jacob22](https://discourse.nodered.org/u/jacob22)\
**Post date:** [8 January 2022 10:52 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/6 "2022-01-08T10:52:58Z")

</div>

i already solved the problem, altough thanks for you answer!

---

<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:** [22 January 2022 10:53 UTC](https://discourse.nodered.org/t/function-node-typeerror-msg-payload-replaceall-is-not-a-function/56288/7 "2022-01-22T10:53:59Z")

</div>

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