Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fenix-hub/unirest-gdscript
Unirest in GDScript: Simplified, lightweight HTTP client library. Godot Engine HTTPClient extension inspired by Kong Unirest.
https://github.com/fenix-hub/unirest-gdscript
gdscript godot hacktoberfest http httpclient unirest
Last synced: about 2 months ago
JSON representation
Unirest in GDScript: Simplified, lightweight HTTP client library. Godot Engine HTTPClient extension inspired by Kong Unirest.
- Host: GitHub
- URL: https://github.com/fenix-hub/unirest-gdscript
- Owner: fenix-hub
- License: mit
- Created: 2022-08-02T14:37:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-15T09:33:07.000Z (11 months ago)
- Last Synced: 2024-05-01T16:38:31.070Z (8 months ago)
- Topics: gdscript, godot, hacktoberfest, http, httpclient, unirest
- Language: GDScript
- Homepage: https://nicolosantilio.com/unirest-gdscript
- Size: 59.6 KB
- Stars: 31
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unirest-gdscript (4.x)
Unirest in GDScript: Simplified, lightweight HTTP client library. Godot Engine HTTPClient extension inspired by Kong Unirest.👉 [3.x](https://github.com/fenix-hub/unirest-gdscript)
### sync example
```gdscript
func _ready() -> void:
var json_response: JsonResponse = await Unirest.Get("https://jsonplaceholder.typicode.com/posts/{id}") \
.header("Accept", "application/json") \
.route_param("id", "1") \
.as_json()
# Execution will stop until Unirest receives a response
var json_node: JsonNode = json_response.get_body()
print(json_node.as_dictionary().get("title"))
```### async example (lambda function)
```gdscript
func _ready() -> void:
Unirest.Get("https://jsonplaceholder.typicode.com/posts/{id}") \
.header("Accept", "application/json") \
.route_param("id", "1") \
.as_json_async(
func(json_response: JsonResponse) -> void:
var title: String = json_response.get_body().as_dictionary().get("title")
print("Title of 1st post is: %s" % title)
)
# Execution won't stop, and the anonymous function will be executed automatically
```### async example (signals)
```gdscript
func _ready() -> void:
Unirest.Get("https://jsonplaceholder.typicode.com/posts/{id}") \
.header("Accept", "application/json") \
.route_param("id", "1") \
.as_json_async() \
.completed.connect(handle_response)
# Execution won't stop here, and your function will be called upon signal emissionfunc handle_response(json_response: JsonResponse) -> void:
var title: String = json_response.get_body().as_dictionary().get("title")
print("Title of 1st post is: %s" % title)
```