1 |
|
2 |
|
3 | /**
|
4 | * This is an example of rfunc client
|
5 | */
|
6 |
|
7 |
|
8 | const apemanApi = require('apeman-api-client')
|
9 | const co = require('co')
|
10 |
|
11 | co(function * () {
|
12 | let api = apemanApi('http://myapp.example.com')
|
13 |
|
14 | let sign = yield api.connect('sign') // Define a client
|
15 |
|
16 | // Call remote api and receive the result
|
17 | let { success } = yield sign.signin('foo', 'bar1234')
|
18 | console.log('success:', success)
|
19 |
|
20 | {
|
21 | // Access to scoped api
|
22 | let admin = api.of('@admin')
|
23 | let user = admin.user()
|
24 | yield user.destroy(1)
|
25 | /* ... */
|
26 | }
|
27 | }).catch((err) => console.error(err))
|