Skip to content

theonjs/superagent-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

superagent-adapter Build Status npm version

super-agent HTTP agent adapter theon.

Installation

npm install theon-superagent-adapter --save

Usage

const theon = require('theon')
const superagent = require('theon-superagent-adapter')

// Define your default HTTP agent
theon.agents.set(superagent)

// Declare your API
const api = theon('http://api.server.com')
  .collection('/users')
  .set('Version', '1.0')
  .resource('getById')
  .path('/:id')
  .render()

// Consume your API
api.users
  .getById()
  .param('id', '1234')
  .expect(200)
  .expect('Content-Type', /json/i)
  .expect({ id: 1234, username: 'foo' })
  .end((err, res) => {
    if (err) {
      return console.error('Expect error:', err)
    }
  })

License

MIT

About

superagent HTTP agent adapter for theon

Resources

License

Stars

Watchers

Forks

Packages

No packages published