mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
feat: http response as table
This commit is contained in:
parent
5f37118f74
commit
ef3a5cf278
2 changed files with 42 additions and 10 deletions
|
|
@ -127,8 +127,12 @@ network.get = function(url, callback, errorCallback, headers)
|
|||
return request(url, {
|
||||
method = "GET",
|
||||
headers = headers,
|
||||
on_response = callback,
|
||||
on_error = errorCallback,
|
||||
on_response = function(response)
|
||||
callback(response.body)
|
||||
end,
|
||||
on_error = function(response)
|
||||
errorCallback(response.status, response.body)
|
||||
end,
|
||||
follow_location = true,
|
||||
})
|
||||
end
|
||||
|
|
@ -137,8 +141,12 @@ network.get_binary = function(url, callback, errorCallback, headers)
|
|||
return request(url, {
|
||||
method = "GET",
|
||||
headers = headers,
|
||||
on_response = callback and (function (response) return callback(Bytearray(response)) end),
|
||||
on_error = errorCallback,
|
||||
on_response = callback and (function (response)
|
||||
return callback(Bytearray(response.body))
|
||||
end),
|
||||
on_error = function(response)
|
||||
errorCallback(response.status, response.body)
|
||||
end,
|
||||
follow_location = true,
|
||||
})
|
||||
end
|
||||
|
|
@ -150,8 +158,12 @@ network.post = function(url, body, callback, errorCallback, headers)
|
|||
"Content-Type: application/json"
|
||||
}, headers),
|
||||
body = body,
|
||||
on_response = callback,
|
||||
on_error = errorCallback,
|
||||
on_response = function(response)
|
||||
callback(response.body)
|
||||
end,
|
||||
on_error = function(response)
|
||||
errorCallback(response.status, response.body)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue