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

ajaxapi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajaxapi

minimal ajax library.

  • 0.0.0-pre4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ajaxapi

minimal ajax library.

  • optimized for consuming restful api's
  • small and compact (< 6kb gzipped)
  • uses promises
  • supports node.js and the browser
var ajaxapi = require('ajaxapi');

var API = ajaxapi('https://api.github.com');

API.get('/repo/iojs/io.js')
  .then(function (data) {
    alert("Stars: " + data.stargazers_count);
  })

API.put('/user', { name: 'John Constantine' })
  .then(function (data) {
    alert("User data was saved");
  });

Customization

Before hooks

Hooks before its sent

var API = ajaxapi('https://api.github.com');

API.before(function (ctx) {
  ctx.headers['X-Access-Token'] = '...';

  ctx.headers   //=> {}
  ctx.method    //=> "GET"
  ctx.url       //=> "https://api.github.com/foo/bar"
  ctx.data      //=> {}
});

After hooks

Promise stuff -- to be appended to the chain via .then() after the body is parsed.

These hooks will be chaining each other.

var API = ajaxapi('https://api.github.com');

API.after(function (data) {
  // do stuff
  API.response.headers
  API.response.statusCode

  return data;
});

FAQs

Package last updated on 03 Feb 2015

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