
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
A javasript library that makes it easy to retrieve JSON data from a JSON file
A Javascript library that allows to abstract all boilerplate from retrieving JSON data using the native ES6 fetch API.
Simple and easy to use, it only abstracts away all the boilerplate required for fetching json data. No other javascript library is required to use this library.
Just like every library should, I tried to make fetchJSON compatible with quite everything I am aware of.
fetchJSON currently supports regular use (via HTML script tag), npm and require (and commonJS), AMD (and probably ES6 modules ?).
Therefore, here are two ways to install this library:
<html>
<!-- [...] -->
<head>
<!-- [...] -->
<script src="path/to/fetchJSON.js"></script>
<!-- [...] -->
</head>
<!-- [...] -->
</html>
npm install fetch_json
const fetchJSON = require("fetch_json");
Sometimes, you just have that json file which's sole purpose is configuration. With fetchJSON, getting the data from this file is very easy:
//With fetchJSON
let config_data;
fetchJSON("../../someFolder/someFile.json", data=>config_data=data);
//Without fetchJSON
let config_data;
fetch("../../someFolder/someFile.json").then(response=>{
/*gather headers*/
if(/*there's json in there*/)
return response.json().then(data=>{
/*some manipulation*/
let config_data = data;
//finally !
});
else
/*handle error*/
})
Once loaded, the data can be used like this:
let config_data;
fetchJSON("../../someFolder/someFile.json", data=>config_data=data)
.then(()=>{
/* use config_data to configure your application*/
});
Please fill free to ask for help / post suggestions on my github repository, I'll be more than glad to take care of your problems/concerns.
FAQs
A javasript library that makes it easy to retrieve JSON data from a JSON file
We found that fetch_json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.