Skip to content

Commit

Permalink
Update README.md (#11)
Browse files Browse the repository at this point in the history
* Update README.md

* Clarify usage of the addon

* Push Version to 2.2.0

---------

Co-authored-by: swarkin <[email protected]>
  • Loading branch information
Beheadedstraw and Swarkin authored Oct 17, 2024
1 parent cf3d73d commit f64e329
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<img alt="project icon: syntax-highlighted text reading 'await http dot request()'" src="addons/awaitable_http_request/icon.png" width="64">
<img alt="project icon: syntax-highlighted text reading 'await http dot request'" src="addons/awaitable_http_request/icon.png" width="64">

## AwaitableHTTPRequest Node for Godot 4

This addon makes HTTP requests much more convenient to use by introducing the `await`-syntax and removing the need for signals.

### Usage

Here is an example with minimal error-handling:

```py
@export var http: AwaitableHTTPRequest
extends AwaitableHTTPRequest

func _ready() -> void:
var resp := await http.async_request("https://api.github.com/users/swarkin")
if resp.success():
print(resp.status) # 200
print(resp.headers["content-type"]) # application/json
var resp := await async_request("https://api.github.com/users/swarkin")
if resp.success() and resp.status_ok():
print(resp.status) # 200
print(resp.headers["content-type"]) # application/json

var json = resp.body_as_json()
print(json["login"]) # Swarkin
var json = resp.body_as_json()
print(json["login"]) # Swarkin
```

See `examples.tscn` for more.
Expand Down
8 changes: 4 additions & 4 deletions addons/awaitable_http_request/awaitable_http_request.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class_name AwaitableHTTPRequest
extends HTTPRequest
## [img width=64]res://addons/awaitable_http_request/icon.png[/img] [url=https://github.com/Swarkin/Godot-AwaitableHTTPRequest]AwaitableHTTPRequest[/url] 2.0.0 by Swarkin & [url=https://github.com/Swarkin/Godot-AwaitableHTTPRequest/graphs/contributors]contributors[/url].
## [img width=64]res://addons/awaitable_http_request/icon.png[/img] [url=https://github.com/Swarkin/Godot-AwaitableHTTPRequest]AwaitableHTTPRequest[/url] 2.2.0 by Swarkin & [url=https://github.com/Swarkin/Godot-AwaitableHTTPRequest/graphs/contributors]contributors[/url].
# View the formatted documentation in Godot by pressing F1 and typing "AwaitableHTTPRequest"!

signal request_finished ## Emits once the current request finishes, right after [member is_requesting] is set to false.
Expand All @@ -13,11 +13,11 @@ var is_requesting := false ## Whether the node is busy performing a request. Th
## [br]
## Here is an example with minimal error-handling:
## [codeblock]
## @export var http: AwaitableHTTPRequest
## extends AwaitableHTTPRequest
##
## func _ready() -> void:
## var resp := await http.async_request("https://api.github.com/users/swarkin")
## if resp.success():
## var resp := await async_request("https://api.github.com/users/swarkin")
## if resp.success() and resp.status_ok():
## print(resp.status) # 200
## print(resp.headers["content-type"]) # application/json
##
Expand Down
2 changes: 1 addition & 1 deletion addons/awaitable_http_request/examples.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func request_api() -> Dictionary:
\"https://api.github.com/users/swarkin\",
PackedStringArray([ # headers
\"accept: application/vnd.github+json\",
\"user-agent: Swarkin/AwaitableHTTPRequest/2.0.0\",
\"user-agent: Swarkin/AwaitableHTTPRequest/2.2.0\",
]),
)

Expand Down
14 changes: 7 additions & 7 deletions addons/awaitable_http_request/plugin.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[plugin]

name="AwaitableHTTPRequest Node"
description="This addon makes HTTP requests much more convenient to use by introducing the await-syntax and removing the need for signals."
author="Swarkin"
version="2.1.1"
script="plugin.gd"
[plugin]

name="AwaitableHTTPRequest Node"
description="This addon makes HTTP requests much more convenient to use by introducing the await-syntax and removing the need for signals."
author="Swarkin"
version="2.2.0"
script="plugin.gd"
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f64e329

Please sign in to comment.