extends HTTPRequest


# Обработчик ответа на HTTP запрос к бэкэнду
func _on_HTTPRequestFind_request_completed(result, response_code, headers, body):
	var resp = body.get_string_from_utf8()
	var parsed_resp = parse_json(resp)
	var simpled_data = parsed_resp['data']['universoObjekto']['edges']
	
	$'../'.ItemListContent.clear()
	$'../canvas/MarginContainer/VBoxContainer/scroll/ItemList'.clear()
	Global.objektoj.clear()
	for item in simpled_data:
		Global.objektoj.append(item['node'])
		var itemj ={
			'nomo':item['node']['nomo']['enhavo'],
			'priskribo':item['node']['priskribo']['enhavo'],
			'uuid':item['node']['uuid'],
			'koordinatoX':item['node']['koordinatoX'],
			'koordinatoY':item['node']['koordinatoY'],
			'koordinatoZ':item['node']['koordinatoZ'],
			'posedantoId':item['node']['posedantoId'],
			'posedantoObjekto':item['node']['posedantoObjekto'],
			'inCosmo':item['node']['inCosmo'],
			'distance':0,
		}
		$'../'.ItemListContent.append(itemj)
	$'../'.FillItemList()
	if $"/root".get_node_or_null('space'):
		$"/root".get_node('space').emit_signal("load_objektoj")
