How to delay an HTTPRequest?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By namathos

Is there a way to delay HTTPRequests?

I’m making a drawing app in Godot, it’s linked to an API that saves drawings to a server. Everything is fine only the first time you press save on the drawing a 0KB file gets uploaded. Second time the button is pressed the drawing gets fully uploaded. What’s more baffling is when a new drawing is made (either by clearing or drawing over the previous one), rather then save the new drawing, the previous drawing is saved on the first button press, and new drawing saved on second same button press.

The image is processed into base64 then sent to server where it’s decoded and saved. I know it’s not an API problem because when trying to send a local PNG file just wired to the button it works flawlessly. It’s only when taking viewport data > processing > sending that this happens.

My theory is the time difference between Godot’s processing the image and sending the data is too little. So back to my question, is there a way to delay HTTPRequests?

EDIT. As a test I made a second button, one to process the image, one to send the data. It works perfectly. What is happening?

:bust_in_silhouette: Reply From: namathos

Found a way, nothing direct with HTTPRequest but using Timer node with it works. Followed things here: https://forum.godotengine.org/9758/timer-node-how-to-use-it-in-code