xhr-request-interceptor

0.1.2 • Public • Published

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();

Package Sidebar

Install

npm i xhr-request-interceptor

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

5.82 kB

Total Files

6

Last publish

Collaborators

  • coderge