Skip to content

Instantly share code, notes, and snippets.

@jonmaim
Last active December 31, 2016 08:56
Show Gist options
  • Save jonmaim/579a0b064728abee63cc01f8ad1f49ff to your computer and use it in GitHub Desktop.
Save jonmaim/579a0b064728abee63cc01f8ad1f49ff to your computer and use it in GitHub Desktop.
Load JSON file
module.exports = function(path, cb) {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json");
xhr.open('GET', path, true);
xhr.onreadystatechange = function() { xhr.readyState === 4 && xhr.status === 200 && cb(JSON.parse(xhr.responseText)); };
xhr.send(null);
};
{
"name": "load_json_file",
"version": "0.1.3"
}
@jonmaim
Copy link
Author

jonmaim commented Dec 31, 2016

Use npm to import this gist:
npm i gist:579a0b064728abee63cc01f8ad1f49ff --save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment