From 5514aefe643761f7624479a5c75f3d0515bd59f4 Mon Sep 17 00:00:00 2001 From: "eryn L. K" Date: Mon, 17 Aug 2020 19:31:08 -0400 Subject: [PATCH] Update README.md --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f217706..c219a10 100644 --- a/README.md +++ b/README.md @@ -30,22 +30,23 @@ local HttpService = game:GetService("HttpService") -- Ideally, you do this once per project per async method that you use. local function httpGet(url) return Promise.new(function(resolve, reject) - local ok, result = pcall(HttpService.GetAsync, HttpService, url) + local result = HttpService:JSONDecode(HttpService:GetAsync(url)) - if ok then - resolve(result) + if result.ok then + resolve(result.data) else - reject(result) + reject(result.error) end end) end -- Usage -httpGet("https://google.com") +httpGet("https://some-api.example") :andThen(function(body) - print("Here's the Google homepage:", body) + print("Here's the web api result:", body) end) :catch(function(err) - warn("We failed to get the Google homepage!", err) + warn("Web api encountered an error:", err) end) ``` +