Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

active-client

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active-client

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Active-Client

This library exists mainly to let HTTP clients treat various error codes correctly and not bundle them under callbacks for success, failure etc. With active-client, you can write better clients such as the one below.

var client = require('active-client');
client.request({
  method: 'POST',
  uri: 'http://www.example.org/something,
  body: 'param1=value&param2=value2',
  headers: {
    'Content-Type' : 'application/x-www-form-urlencoded'
  },
  '401' : function(res) {
    // Not authorized - do something about it 
     ...
  },
  '4xx' : function(res) {
    // Other 4xx errors
  },
  '5xx' : function(res) {
    // Broken server?
    ...
  },
  '200' : function(res) {
    // Handle 'on', 'data', 'end' etc on the res object as you would do with nodejs
    res.on('data', function(chunk) { 
      ...
    });
    res.on('end', function() {
      ...
    });
  }
});

That's all!

Use npm install active-client to get active-client.

FAQs

Package last updated on 03 Jan 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc