
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
changed-http
Advanced tools
Polls HTTP resources and fires events when they change.
npm install robinjmurphy/changed
var changed = require('changed-http');
var resource = new changed.Resource('http://www.example.com');
resource.on('changed', function (current, previous) {
console.log('Resource changed. Response body was ' + previous + ' , is now ' + current + '.');
});
resource.startPolling(5000);
new changed.Resource(url, options)url - stringoptions - object - configuration optionsThe options object supports all of the standard options from http.request and https.request. In addition, it supports the following properties:
compare - function - overrides the default response body comparison. Receives the current response body as its first argument and the previous response body as its second argument. Should return true if the responses differ..startPolling(interval)Start polling the resource for changes.
interval - number - the interval time in milliseconds (default 10000).stopPolling()Stop polling the resource.
changedFired when the resource's body changes.
resource.on('changed', function (current, previous) {
// `current` is a string containing the curent response body
// `previous` is a string containing previous response body
});
errorFired when an error occurs.
resource.on('error', function (error) {
// `error` is an Error object
});
responseFired each time a response is received whilst polling.
resource.on('response', function (body, res) {
// `body` is a string containig the response body
// `res` is the http/https response object
});
All polling requests are logged using console.info by default. To use a custom logger, like Winston, just set the changed.logger property:
var changed = require('changed-http');
var winston = require('winston');
changed.logger = winston;
In the following example the changed event is only fired when the foo property in a JSON response changes.
var changed = require('changed-http');
var resource = new changed.Resource('http://www.example.com/some/json/file.json', {
compare: function (current, previous) {
var currentJson = JSON.parse(current);
var previousJson = JSON.parse(previous);
return (currentJson.foo !== previousJson.foo);
}
});
resource.startPolling(5000);
FAQs
Polls HTTP resources and fires events when they change
The npm package changed-http receives a total of 3,391 weekly downloads. As such, changed-http popularity was classified as popular.
We found that changed-http 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.