# Wait for page load before make Get request

**URL:** <https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405>\
**Category:** General\
**Created:** [26 February 2019 13:25 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405 "2019-02-26T13:25:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dandres/32/6308_2.png) [@dandres](https://discourse.nodered.org/u/dandres)\
**Post date:** [26 February 2019 13:25 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/1 "2019-02-26T13:25:13Z")

</div>

I use http-request node with method GET, but the page takes a long time to finish loading, so it gives me a value of 0 where a larger number should go.  
How could I solve it?

---

<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:** [26 February 2019 16:10 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/2 "2019-02-26T16:10:45Z")

</div>

I don't understand what you mean. The request node should not pass on anything till it has the complete page.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 February 2019 16:34 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/3 "2019-02-26T16:34:50Z")

</div>

I agree with Colin it shouldn’t pass anything on until the page completes. Unless it is timing out.

I would suggest putting a debug on the http request node to see what it is actually passing.

And paste that and your flow here

---

<div class="post-metadata">

**Author:** ![dandres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dandres/32/6308_2.png) [@dandres](https://discourse.nodered.org/u/dandres)\
**Post date:** [26 February 2019 16:40 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/4 "2019-02-26T16:40:04Z")

</div>

Is simple, inject + http request + debug

```auto
[{"id":"26e9db6e.00e074","type":"inject","z":"196c04a7.1fbc3b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":120,"wires":[["55c397f5.230f88"]]},{"id":"55c397f5.230f88","type":"http request","z":"196c04a7.1fbc3b","name":"","method":"GET","ret":"txt","url":"https://apsystemsema.com/ema/intoDemoUser.action?id=000000006661d922016663efb55a0188&locale=en_US","tls":"","x":430,"y":120,"wires":[["ffe64d19.9889b"]]},{"id":"ffe64d19.9889b","type":"html","z":"196c04a7.1fbc3b","name":"","property":"payload","outproperty":"payload","tag":"#today","ret":"html","as":"multi","x":590,"y":120,"wires":[["4bf7a7c4.585858"]]},{"id":"4bf7a7c4.585858","type":"debug","z":"196c04a7.1fbc3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":120,"wires":[]}]

```

 ![wait](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0afb202859e120d144e93fc181373e69558beb75.png)

The page takes a couple of seconds to load its values

---

<div class="post-metadata">

**Author:** ![Stylo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stylo/32/14221_2.png) [@Stylo](https://discourse.nodered.org/u/Stylo)\
**Post date:** [26 February 2019 16:47 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/5 "2019-02-26T16:47:01Z")

</div>

Your code isn't currently importable, you need to format it correctly in the forum. Please see this thread; [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [26 February 2019 16:55 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/6 "2019-02-26T16:55:27Z")

</div>

Try loading the page in your web browser with javascript disabled/turned off ( look at the developer options)  
Does that then match what Node-RED sees?

---

<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:** [26 February 2019 16:59 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/7 "2019-02-26T16:59:50Z")

</div>

So, to fill in the missing details of your question, you make an HTTP Request of a page and then use an HTML node to find the element with id `today` to get its value.

When you load that page in your browser and View Source, you can see that element has a value of `0` - that is what Node-RED will get.

This is because the page uses javascript to dynamically change that value after the page has loaded. The HTTP Request node does _not_ evaluate javascript when it retrieves a webpage - so any dynamically generated content will not be there.

You would need to dig deeper into how the page is loading the data you want, and then do the same with your Node-RED flow. You can use the browser developer tools to figure out what HTTP requests the page is making to the load the data dynamically.

---

<div class="post-metadata">

**Author:** ![dandres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dandres/32/6308_2.png) [@dandres](https://discourse.nodered.org/u/dandres)\
**Post date:** [26 February 2019 18:22 UTC](https://discourse.nodered.org/t/wait-for-page-load-before-make-get-request/8405/8 "2019-02-26T18:22:31Z")

</div>

Thanks for your help, I will look how to work on it 🙂
