Skip to content

Latest commit

 

History

History
 
 

universal-jsonp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

universal-jsonp npm

jsonp like standard Fetch API

Install

$ npm install universal-jsonp --save

Usage

import jsonp from 'universal-jsonp';

jsonp('/users.jsonp')
  .then(function(response) {
    return response.json()
  }).then(function(json) {
    console.log('parsed json', json)
  }).catch(function(err) {
    console.log('parsing failed', err)
  });

APIS

jsonp(url, options)

  • url: Required, String, jsonp url
  • options: Optional, Object, options attributes:
    • timeout: Number, default 5000ms
    • jsonpCallback: String, default callback
    • jsonpCallbackFunctionName: String, default randomly generated