0xjs README/website docs update

This commit is contained in:
Jacob Evans
2018-09-13 13:51:09 +02:00
parent df5779b6d1
commit cf46d2c704
13 changed files with 111 additions and 30 deletions

View File

@@ -0,0 +1,26 @@
0x.js is a promise-based library. This means that whenever an asynchronous call is required, the library method will return a native Javascript promise. You can therefore choose between using `promise` or `async/await` syntax when calling our async methods.
_Async/await syntax (recommended):_
```javascript
try {
var availableAddresses = await zeroEx.getAvailableAddressesAsync();
} catch (error) {
console.log('Caught error: ', error);
}
```
_Promise syntax:_
```javascript
zeroEx
.getAvailableAddressesAsync()
.then(function(availableAddresses) {
console.log(availableAddresses);
})
.catch(function(error) {
console.log('Caught error: ', error);
});
```
As is the convention with promise-based libraries, if an error occurs, it is thrown. It is the callers responsibility to catch thrown errors and to handle them appropriately.