You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jsonp_p

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonp_p

Promise based jsonp

0.0.3
latest
npmnpm
Version published
Maintainers
2
Created
Source

Build Status

jsonp_p

Jsonp in Promise and callback mode.

Installing

npm install jsonp_p

Usage

import jsonp from "jsonp_p";

// Promise mode
jsonp({
  url: "http://jsfiddle.net/echo/jsonp/",
  params: {
    name: "jsonp_p",
    version: "0.0.1"
  },
  callback: "jsonp"
}).then(data => {
  console.log(data);
  //{name: 'jsonp_p',version: '0.0.1'}
});

// callback mode
jsonp({
  url: "http://jsfiddle.net/echo/jsonp/",
  params: {
    name: "jsonp_p",
    version: "0.0.1"
  },
  callback: "jsonp",
  onSuccess(data) {
    console.log(data);
    //{name: 'jsonp_p',version: '0.0.1'}
  }
});

options

url

type url = string;

request url

[params]

type params = object;

query string defaultencodeURI

[callback]

type callback = string;

callback name

[timeout]

type timeout = number;

[onSuccess]

type onSuccess = (res: object) => any;

If callback mode is preferred, then a function can be passed to onSuccess

[onError]

type onError = (err: Error) => any;

Just like onSuccess, available if callback mode is preferred

Callback and Promise

jsonp_p supports callback mode now.

If a global Promise is available, jsonp_p can also run in Promise mode.

If your environment doesn't support Promise, you can add polyfill.

Keywords

jsonp

FAQs

Package last updated on 18 Feb 2019

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