Thanks to visit codestin.com
Credit goes to github.com

Skip to content

diversen/get-json-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

MIT © Dennis Iversen

About

Tiny module for getting JSON from a URL as a promise.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published