Introduction to Promises
Promises in code are cool:tm:
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
Example:
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:
Is this code too long / complicated for you? We can simplify it even further!
For a more in-depth explanation than whatever this is, check out this post by evaera. This is the code that is used.
Last updated