https://github.com/diversen/get-json-promise
Tiny module for getting JSON from a URL as a promise.
https://github.com/diversen/get-json-promise
get-json
Last synced: about 1 year ago
JSON representation
Tiny module for getting JSON from a URL as a promise.
- Host: GitHub
- URL: https://github.com/diversen/get-json-promise
- Owner: diversen
- Created: 2017-09-24T11:09:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-13T21:05:59.000Z (almost 9 years ago)
- Last Synced: 2025-06-22T07:03:53.221Z (about 1 year ago)
- Topics: get-json
- Language: JavaScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Get json promise
Tiny module for getting JSON from a URL as a promise.
Will only work where the XMLHttpRequest exists, which is not native in e.g. nodejs.
It also does not include any promise library - so it may not work in older browsers.
## Install
npm require --save get-json-promise
## Usage
~~~js
var jsonPromise = require('get-json-promise');
var url = 'http://localhost:8080/package.json';
jsonPromise(url).then(function(data) {
console.log(data);
// Returns object JSON.parse
});
~~~
Example in a HTML page:
See [index.html](index.html)
MIT © [Dennis Iversen](https://github.com/diversen)