mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
Update README.md
This commit is contained in:
parent
264ff27213
commit
7c3ce0f809
1 changed files with 7 additions and 9 deletions
16
README.md
16
README.md
|
@ -31,16 +31,14 @@ local HttpService = game:GetService("HttpService")
|
|||
-- A light wrapper around HttpService
|
||||
-- Ideally, you do this once per project per async method that you use.
|
||||
local function httpGet(url)
|
||||
return Promise.new(function(resolve, reject)
|
||||
Promise.spawn(function()
|
||||
local ok, result = pcall(HttpService.GetAsync, HttpService, url)
|
||||
return Promise.async(function(resolve, reject)
|
||||
local ok, result = pcall(HttpService.GetAsync, HttpService, url)
|
||||
|
||||
if ok then
|
||||
resolve(result)
|
||||
else
|
||||
reject(result)
|
||||
end
|
||||
end)
|
||||
if ok then
|
||||
resolve(result)
|
||||
else
|
||||
reject(result)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue