# Function with Puppeteer

**URL:** <https://discourse.nodered.org/t/function-with-puppeteer/79401>\
**Category:** General\
**Created:** [25 June 2023 11:19 UTC](https://discourse.nodered.org/t/function-with-puppeteer/79401 "2023-06-25T11:19:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [25 June 2023 11:19 UTC](https://discourse.nodered.org/t/function-with-puppeteer/79401/1 "2023-06-25T11:19:00Z")

</div>

Hi  
I have a working javascript file that uses Puppeteer to submit a form. I would like to use this in a Node Red function, I have added the puppeteer library in the set up of the function but there are errors in the function on document. I have attached a screenshot. Any advice appreciated

 ![PuppeteerFunction](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea942ce09c036f1e501b5adcb1c8a955d0e909a9.jpeg)

---

<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 June 2023 11:46 UTC](https://discourse.nodered.org/t/function-with-puppeteer/79401/2 "2023-06-25T11:46:54Z")

</div>

> [@mtoko](#):
>
> I would like to use this in a Node Red function

Functions run in the node-red runtime (in node, not in a browser). Therefore there is no document object.

That doesn't mean it is not doable. The [example](https://pptr.dev/#example) in the readme _might_ work out of the box.

However: do you _really_ need to run puppeteer? It is quite heavy weight. Can't you simply do a HTTP POST using the built in HTTP request node?

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [25 June 2023 14:24 UTC](https://discourse.nodered.org/t/function-with-puppeteer/79401/3 "2023-06-25T14:24:14Z")

</div>

Thanks Steve, I did try and HTTP request and then a POST but couldn't get it to work. This was plan B

---

<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:** [24 August 2023 14:24 UTC](https://discourse.nodered.org/t/function-with-puppeteer/79401/4 "2023-08-24T14:24:57Z")

</div>

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