Skip to content

Commit 4f55aa5

Browse files
committed
2 parents 9b5a39d + 5514aef commit 4f55aa5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ local HttpService = game:GetService("HttpService")
3030
-- Ideally, you do this once per project per async method that you use.
3131
local function httpGet(url)
3232
return Promise.new(function(resolve, reject)
33-
local ok, result = pcall(HttpService.GetAsync, HttpService, url)
33+
local result = HttpService:JSONDecode(HttpService:GetAsync(url))
3434

35-
if ok then
36-
resolve(result)
35+
if result.ok then
36+
resolve(result.data)
3737
else
38-
reject(result)
38+
reject(result.error)
3939
end
4040
end)
4141
end
4242

4343
-- Usage
44-
httpGet("https://google.com")
44+
httpGet("https://some-api.example")
4545
:andThen(function(body)
46-
print("Here's the Google homepage:", body)
46+
print("Here's the web api result:", body)
4747
end)
4848
:catch(function(err)
49-
warn("We failed to get the Google homepage!", err)
49+
warn("Web api encountered an error:", err)
5050
end)
5151
```
52+

0 commit comments

Comments
 (0)