Roblox Requests now supports Roblox Lua Promises. I think this addition will make the library more useful to many Roblox devs looking for a more robust solution for HTTP requests in Roblox.
Here’s an example of using the library’s existing methods with Promises:
http.promise_get("https://api.github.com/orgs/this_org_does_not_exist/repos")
:andThen(function(response)
for _, repo in ipairs(response:json()) do
print(repo.name)
end
end)
:catch(function(err)
if err.request_sent then
print("HTTP Error:", err.response.status_code, err.response.message)
else
print(err.error)
end
end)
-- HTTP Error: 404 Not Found
For more info on using Promises, see the project documentation:
Here’s an example use case that finds all the links on GitHub’s front page:
local document = http.get("https://github.com"):html()
for _, url in ipairs(document:absolute_links()) do
print(url)
end
-- https://github.com/#start-of-content
-- https://help.github.com/articles/supported-browsers
-- https://github.com/
-- https://github.com/join?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F&source=header-home
-- ...
Wow, this library’s a hidden gem! As a big fan of the Python requests library, I’m in love already
I noticed a tiny issue with sending files using multipart/form-data, wherein extra \r\n was preceding my data. I submitted an issue (#16) and a pull request which fixes it over on GitHub. It was causing me trouble while using the Telegram Bot API’s sendDocument method.
If you’re talking about importing the Roblox Requests module into repl then no, It will not work that was as repl does not have support for Roblox Engine API’s like HttpService.
If you’re asking if you can use Roblox Requests to communicate with your API deployed on repl then yes. Roblox Requests is just a wrapper of HttpService that allows you to more easily write and handle requests.