RbxProxy
  • Introduction
    • Installation
    • Introduction to Promises
    • Introduction to Pages
  • Reference
    • API Reference
      • Client
      • Avatar
      • Friends
      • Game
      • Group
      • User
Powered by GitBook
On this page
  1. Introduction

Introduction to Promises

Promises in code are cool:tm:

PreviousInstallationNextIntroduction to Pages

Last updated 3 years ago

Promises are cool objects that can handle errors efficiently and asynchronously. We use this on the proxy to handle HTTP requests, because they can be unstable this prevents it from having 15,000 errors in the console.

Credits for promises go to

Example:

api.trySomething(true):andThen(function(response)
    print("that something went right!")
end):catch(function(err)
    print("that something did not go right")
end)
print("this will print instantly")

If it errored, it'd go to the catch function as "err", but if it succeeded then it'll go to the "response" field. This is how most of the API functions in this module work.

If you want to wait for the value to be returned you can add ":await" like this:

api.trySomething(true):andThen(function(response)
    print("that something went right!")
end):catch(function(err)
    print("that something did not go right")
end):await()
print("this will print after")

Is this code too long / complicated for you? We can simplify it even further!

-- example code:
local success,response = client.group:getGroupInformation(1):await();

For a more in-depth explanation than whatever this is, . This is the code that is used.

evaera
check out this post by evaera