mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
Update http_request_class.rst (#7619)
Co-authored-by: Raul Santos <raulsntos@gmail.com>
This commit is contained in:
committed by
Max Hilbrunner
parent
a1e5d43fe3
commit
0af2d80aaa
@@ -78,20 +78,21 @@ look for the ``name`` field and print that to console.
|
||||
.. code-tab:: csharp
|
||||
|
||||
using Godot;
|
||||
using System.Text;
|
||||
|
||||
public partial class MyNode : Node
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
GetNode("HTTPRequest").RequestCompleted += OnRequestCompleted;
|
||||
HttpRequest httpRequest = GetNode<HttpRequest>("HTTPRequest");
|
||||
httpRequest.RequestCompleted += OnRequestCompleted;
|
||||
httpRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
|
||||
}
|
||||
|
||||
private void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
|
||||
{
|
||||
JsonParseResult json = Json.Parse(Encoding.UTF8.GetString(body));
|
||||
GD.Print(json.Result);
|
||||
Godot.Collections.Dictionary json = Json.ParseString(Encoding.UTF8.GetString(body)).AsGodotDictionary();
|
||||
GD.Print(json["name"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user