
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
axios-get-json-response
Advanced tools
A small utility for validating an axios response and parsing it as JSON, *with* distinguishable error types
A simple utility for checking status codes and parsing JSON data from Axios responses. While Axios can do this by itself, it doesn't document any distinguishable error types, and so when an error occurs you can never know what went wrong.
This library fixes that, by giving you two distinct error types. Hopefully this functionality eventually makes it into Axios itself.
Both error types correctly inherit from Error, and therefore a) have stacktraces, and b) can be used with instanceof as well as things based on it, like Bluebird's filtered .catch.
An existent and valid URL:
"use strict";
const axios = require("axios");
const Promise = require("bluebird");
const getJson = require("axios-get-json-response");
Promise.try(() => {
return axios.get("http://cryto.net/test.json", getJson.axiosConfiguration); // {"hello": "world"}
}).then((response) => {
let parsedJson = getJson.parse(response);
console.log(parsedJson); // { hello: 'world' }
});
Using axios.create to set the custom configuration as a default, and showing the result for an existent URL that is not valid JSON:
"use strict";
const axios = require("axios");
const Promise = require("bluebird");
const getJson = require("axios-get-json-response");
let manualAxios = axios.create(getJson.axiosConfiguration);
Promise.try(() => {
return manualAxios.get("http://cryto.net/invalid.json"); // {"hello": "world"
}).then((response) => {
let parsedJson = getJson.parse(response);
/* throws: ParsingFailed: Could not parse response body as JSON */
console.log(parsedJson);
});
The result for a non-existent URL:
"use strict";
const axios = require("axios");
const Promise = require("bluebird");
const getJson = require("axios-get-json-response");
let manualAxios = axios.create(getJson.axiosConfiguration);
Promise.try(() => {
return manualAxios.get("http://cryto.net/non-existent.json"); // URL does not exist
}).then((response) => {
let parsedJson = getJson.parse(response);
/* throws: BadResponseCode: Got an unexpected HTTP status code (404) */
console.log(parsedJson);
});
Some preset configuration options, that disable response code checking and body parsing in Axios. Needed for this library to work. These options are fed directly into Axios; see the example.
Validates the status code and parses the response body. Returns the parsed JSON if successful, or throws either a BadStatusCode or ParsingFailed error depending on what went wrong (see below).
true for a valid/expected status code, and false for an unexpected one.An error type that signifies that an unexpected status code was received.
Extra properties on this error object:
An error type that signifies that the response body could not be parsed as JSON.
console.log.Initial release.
FAQs
A small utility for validating an axios response and parsing it as JSON, *with* distinguishable error types
We found that axios-get-json-response 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.