48 lines
962 B
GDScript3
48 lines
962 B
GDScript3
|
extends VBoxContainer
|
||
|
|
||
|
var username = ""
|
||
|
var password = ""
|
||
|
var url: String = "http://localhost:8080/api/v1/player/login"
|
||
|
var headers = ["Content-Type: application/json"]
|
||
|
|
||
|
|
||
|
func _ready() -> void:
|
||
|
pass
|
||
|
|
||
|
|
||
|
|
||
|
func _process(delta: float) -> void:
|
||
|
pass
|
||
|
|
||
|
|
||
|
func _on_username_input_text_changed(new_text: String) -> void:
|
||
|
username = new_text
|
||
|
pass
|
||
|
|
||
|
|
||
|
func _on_password_input_text_changed(new_text: String) -> void:
|
||
|
password = new_text
|
||
|
pass
|
||
|
|
||
|
|
||
|
func _on_button_button_up() -> void:
|
||
|
var loginData = {"username": username, "password": password}
|
||
|
var json = JSON.stringify(loginData)
|
||
|
|
||
|
print(username)
|
||
|
print(password)
|
||
|
#$HTTPRequest.request("https://catfact.ninja/fact")
|
||
|
$HTTPRequest.request(url, headers, HTTPClient.METHOD_POST, json)
|
||
|
print(json)
|
||
|
pass
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
func _on_http_request_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
||
|
print(body.get_string_from_utf8())
|