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