Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onConnect() {
const { context } = this.options;
const fakeXhrForContext = fakeXhr.fakeXMLHttpRequestFor(context);
this.assert('XHR global not found.', fakeXhrForContext.xhr.supportsXHR);
this.assert(
'Running concurrent XHR adapters is unsupported, stop any running Polly instances.',
!stubbedXhrs.has(context.XMLHttpRequest)
);
this.NativeXMLHttpRequest = context.XMLHttpRequest;
this.xhr = fakeXhrForContext.useFakeXMLHttpRequest();
this.xhr.onCreate = xhr => {
xhr[SEND] = xhr.send;
xhr.send = body => {
xhr[SEND](body);
this.handleRequest({
url: xhr.url,