README.md 843 Bytes
Newer Older
Jarrod's avatar
Jarrod committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# sails-cloud-sdk

```js
import CloudSDK from '@nahanil/sails-cloud-sdk'

const options = {
  baseUrl: 'http://wankieboomboom.com',
  methods: {
    getNudiePics: {
      method: 'GET',
      url: '/api/v1/pics/nekked',
      args: [
        'page',
        'limit'
      ],
       protocol: '...?'
    }
  }
}
CloudSDK.setup(options)
// Or.. client = CloudSDK.create(options)

CloudSDK.getNudiePics({ page: 1, limit: 'alldapr0n' })
  .then(doWank)
  .catch(cry)

// It's basically just axios - y'all can use it directly
CloudSDK.$http.get('/foo')
  .then(() => {})
  .catch(() => {})

// Or..
CloudSDK.$socket.on('boom', () => console.log('DUCK AND COVER PEOPLE'))
Jarrod's avatar
Jarrod committed
34 35 36 37 38 39 40 41 42 43

// Intercept (http|socket) responses
CloudSDK.addInterceptor(function (res) {
  if (res.status === 420) {
    alert('Calm down, Elizabeth!')
    return
  }

  return res
})
Jarrod's avatar
Jarrod committed
44
```