Update README.

This commit is contained in:
Julien Fontanet 2015-02-23 12:25:30 +01:00
parent fd066e5eef
commit 6e42a67268

View File

@ -28,13 +28,29 @@ This high-level interface handles session sign-in and a cache of
remote XO objects. It also automatically reconnect and retry method
calls when necessary.
```javascript
// Connect to XO.
var xo = new xoLib.Xo('https://xo.company.tld');
// Must sign in before being able to call any methods (all calls will
// be buffered until signed in).
xo.signIn({
email: 'admin@admin.net',
password: 'admin',
}).then(function () {
console('signed as', xo.user);
});
```
The credentials can also be passed directly to the constructor:
```javascript
var xo = new xoLib.Xo({
url: 'https://xo.company.tld',
auth: {
credentials: {
email: 'admin@admin.net',
password: 'admin',
},
}
});
```