Skip to content

This permits to wire interceptors on XHR requests and responses

License

Notifications You must be signed in to change notification settings

fbarbare/xhr-intercept

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xhr-intercept

Install

npm i -S xhr-intercept

API

import XhrIntercept from 'xhr-intercept';

function onRequest(xhr, args) {
  console.debug('request', xhr);

  // Return false to cancel the request
  return false;
}

function onResponse(xhr) {
  console.debug('request', xhr);
}

// Add a callback on request or response
XhrIntercept.addRequestCallback(onRequest);
XhrIntercept.addResponseCallback(onResponse);

// Starting intercepting requests
XhrIntercept.wire();

// Remove a callback on request or response
XhrIntercept.removeRequestCallback(onRequest);
XhrIntercept.removeResponseCallback(onResponse);

// Stopping intercepting requests
XhrIntercept.unwire();

About

This permits to wire interceptors on XHR requests and responses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%