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

cormoran

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

cormoran

Light weight library to manage JSONP calls using Promises

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cormoran Build Status

Light weight library to manage JSONP calls using Promises

Install

Download the distribution version and include it on your web project or add it as a dependency

npm install cormoran --save

Use

If you know how Promises in JavaScript work and what is a JSONP call, then you don't need much else.

Require the package or use the global cormoran namespace and run getpassing a url, pipe a then statement to handle the data you've received and catch just in case something goes wrong.

var cormoran = require('cormoran');

cormoran
    .get('https://api.github.com/users/jeremenichelli')
    .then(function(data) {
        console.log(data);
    })
    .catch(function(e) {
        console.error(e);
    });

Configuration

As the callback name and query can changed depending on the API you're trying to reach you can change both of them running this two methods before using the get method.

naming

cormoran.naming('JSONP_CALLBACK');

query

cormoran.query('?callback');

Following the first example the final url would be https://api.github.com/users/jeremenichelli?callback=JSONP_CALLBACK0, a number will be added at the end of every callback name to make them unique.

Notes

Since this library relies on Promises remember to include a polyfill for browsers which don't support this feature. I recommend this one https://github.com/jakearchibald/es6-promise developed by Jake Archibald.

Keywords

FAQs

Package last updated on 08 Jun 2016

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