# Introduction to Promises

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 [evaera](https://devforum.roblox.com/u/evaera/summary)

**Example**:

```lua
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:

```lua
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!

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

For a more in-depth explanation than whatever this is, [check out this post by evaera](https://devforum.roblox.com/t/promises-and-why-you-should-use-them/350825). This is the code that is used.
