mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 13:15:50 +00:00
Clean up and start work on Epiphany plugin
This commit is contained in:
@@ -18,38 +18,47 @@ local Http = {}
|
||||
|
||||
function Http.get(url)
|
||||
dprint("\nGET", url)
|
||||
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return HttpService:GetAsync(url, true)
|
||||
coroutine.wrap(function()
|
||||
local success, response = pcall(function()
|
||||
return HttpService:RequestAsync({
|
||||
Url = url,
|
||||
Method = "GET",
|
||||
})
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result)
|
||||
resolve(HttpResponse.new(result))
|
||||
if success then
|
||||
dprint("\t", response)
|
||||
resolve(HttpResponse.fromRobloxResponse(response))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
reject(HttpError.fromErrorString(response))
|
||||
end
|
||||
end)
|
||||
end)()
|
||||
end)
|
||||
end
|
||||
|
||||
function Http.post(url, body)
|
||||
dprint("\nPOST", url)
|
||||
dprint(body)
|
||||
dprint(body);
|
||||
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return HttpService:PostAsync(url, body)
|
||||
coroutine.wrap(function()
|
||||
local success, response = pcall(function()
|
||||
return HttpService:RequestAsync({
|
||||
Url = url,
|
||||
Method = "POST",
|
||||
Body = body,
|
||||
})
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result)
|
||||
resolve(HttpResponse.new(result))
|
||||
if success then
|
||||
dprint("\t", response)
|
||||
resolve(HttpResponse.fromRobloxResponse(response))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
reject(HttpError.fromErrorString(response))
|
||||
end
|
||||
end)
|
||||
end)()
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user