https://github.com/developit/jasonp
An itty bitty JSONP module
https://github.com/developit/jasonp
Last synced: 9 months ago
JSON representation
An itty bitty JSONP module
- Host: GitHub
- URL: https://github.com/developit/jasonp
- Owner: developit
- Created: 2015-08-04T01:40:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T14:51:21.000Z (over 8 years ago)
- Last Synced: 2025-04-10T11:16:07.933Z (9 months ago)
- Language: JavaScript
- Homepage: http://npm.im/jasonp
- Size: 9.77 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jasonp [![npm]](http://npm.im/jasonp) [![bower]](http://bower.io/search/?q=jasonp)
======
A tiny module that provides a logical interface for making JSONP requests.
> _This is supposed to be funny because my name is Jason._
Usage
-----
##### `jasonp(url, callback) -> (err, ...data)`
Make a JSONP request.
* The callback is node-style (works nicely with [praline]).
* Include a `{{callback}}` placeholder in the URL to replace it with the callback ID.
* Requests time out after 10 seconds with `err='Timed out'`
Example
-------
```js
import get from 'jasonp';
let url = 'http://foo.com/test.json';
get(`${url}?callback={{callback}}`, (err, ...data) => {
if (err) return console.error(err);
console.log(...data);
});
```
License
-------
MIT
[npm]: https://img.shields.io/npm/v/jasonp.svg
[bower]: https://img.shields.io/bower/v/jasonp.svg
[praline]: (https://github.com/developit/praline)