HTTP Request is never completed (trying to show an image from the web)

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

I copy pasted the bottom example ('Example of loading and displaying an image using HTTPRequest:) from the docs:

Can’t get it to work. Brand new project, completely empty. Just a single node with that example code and a print statement in the _http_request_completed function to check if the code ever gets there.

It doesn’t.

my full code

extends Node2D

func _ready():
	# Create an HTTP request node and connect its completion signal.
	var http_request =
	http_request.connect("request_completed", self, "_http_request_completed")

	# Perform the HTTP request. The URL below returns a PNG image as of writing.
	var error = http_request.request("")
	if error != OK:
		push_error("An error occurred in the HTTP request.")

# Called when the HTTP request is completed.
func _http_request_completed(result, response_code, headers, body):
	var image =
	var error = image.load_png_from_buffer(body)
	if error != OK:
		push_error("Couldn't load the image.")

	var texture =

	# Display the image in a TextureRect node.
	var texture_rect =
	texture_rect.texture = texture
:bust_in_silhouette: Reply From: TheJollyReaper

Instead of creating a HTTPRequest node through code, I added one through the visual editor and connected the signal through there too. So all I have in the ready function now is $HTTPRequest.request(‘url’) and it works fine now.