Topic was automatically imported from the old Question2Answer platform.
Asked By
Suleymanov
I am trying to understand the basics of sending data to a server and bringing data back to a device.
Can you please show me an example how I can send a simple numeric value to my server computer, store it in already created .txt document, then call it back to the device?
func _ready():
var xhr = HTTPRequest.new();
xhr.connect("request_completed", self, "OnRequestCompleted");
var body = {"num": 5}
var status = xhr.request("127.0.0.1/numfile", [], true, HTTPClient.METHOD_POST, body)
if status != OK:
push_error("Something went wrong :(")
func OnRequestCompleted(result, response_code, headers, body):
print(body.get_string_from_utf8())
You need to create a num_file in your server and write it, for example, in PHP.