Nethop is a Minimal Network Hook Library for Web Testing and Mock Data
For basic logging, you can use:
// Assuming you've imported Nethop.
// Run the hook command
Nethop.hook();
// After hooking, add a middleware.
Nethop.addMiddleware( interceptor => {
// Log the requests only
if ( interceptor.type === 'request' )
console.log( interceptor.request );
} );
// Make any Fetch or XMLHttpRequest calls here.For intercepting requests, you can use:
// Assuming you've imported Nethop and hooked it.
Nethop.addMiddleware( interceptor => {
// Log the requests only
if ( interceptor.type === 'request'
&& interceptor.request.url.endsWith( '/debug' ) )
interceptor.intercept(
new Nethop.HTTPCode( '200', 'OK' ),
{ /* Leaving headers empty */ },
JSON.stringify( {
isDebug: true
} )
);
} );
// Make any Fetch or XMLHttpRequest calls here./* Hooks onto the network calls */
Nethop.Hook()
/* Middleware Management */
Nethop.addMiddleware( mw: Function )
Nethop.removeMiddleware( mw: Function )
/* Helper classes */
new Nethop.HTTPCode( code: Number, status: String )
/* Internals */
InterceptableRequest.type: String
InterceptableRequest.request: Request
InterceptableRequest.intercept( code: HTTPCode, headers: Object, data: Any )