asingcrow/godot/mastotest.gd

30 lines
814 B
GDScript3

extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
$HTTPRequest.request("http://toot.martyn.berlin/api/v1/timelines/tag/cat")
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
for slice in $GridContainer.get_children():
slice.remove_and_skip()
var json = JSON.parse(body.get_string_from_utf8())
if json.result != null:
for toot in json.result:
var tootitem = Label.new()
tootitem.text = toot.account.display_name+": "+toot.content
$GridContainer.add_child(tootitem)
pass # Replace with function body.