repo-utils/gitlab — pull request #7 by fengmk2 (2014-10-12 03:39:19+00:00)
Title: Promise and thunk

### Thunk way

Require [co](https://github.com/visionmedia/co) and node >= `0.11.12`:

```js
var co = require('co');
var gitlab = require('node-gitlab');

var client = gitlab.createThunk({
api: 'https://gitlab.com/api/v3',
privateToken: 'your private token'
});

co(function* () {
var milestones = yield client.milestones.list({id: 1});
})();
```

### Promise way

Require node >= `0.11.13` or [bluebird](https://github.com/petkaantonov/bluebird):

```js
var gitlab = require('node-gitlab');

var client = gitlab.createPromise({
api: 'https://gitlab.com/api/v3',
privateToken: 'your private token'
});

client.milestones.list({id: 1})
.then(function (milestones) {
console.log(milestones);
})
.catch(function (err) {
throw err;
});
```