19 lines
608 B
Markdown
19 lines
608 B
Markdown
```python
|
|
extends Control
|
|
|
|
@onready var http_request: HTTPRequest = $btn_login/HTTPRequest
|
|
@onready var te_result: TextEdit = $te_result
|
|
|
|
var url = "https://meowfacts.herokuapp.com/"
|
|
|
|
func _on_btn_login_button_up() -> void:
|
|
var headers = ["Content-Type: application/json"]
|
|
http_request.request(url, headers, HTTPClient.Method.METHOD_GET)
|
|
|
|
func _on_http_request_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
|
var data = JSON.parse_string(body.get_string_from_utf8())
|
|
te_result.text = data.data[0]
|
|
```
|
|
|
|
![[Pasted image 20241222121529.png]]
|
|
|