MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / send

Method send

Libraries/Network/XMLHttpRequest.js:451–507  ·  view source on GitHub ↗
(data: any)

Source from the content-addressed store, hash-verified

449 }
450
451 send(data: any): void {
452 if (this.readyState !== this.OPENED) {
453 throw new Error('Request has not been opened');
454 }
455 if (this._sent) {
456 throw new Error('Request has already been sent');
457 }
458 this._sent = true;
459 const incrementalEvents = this._incrementalEvents ||
460 !!this.onreadystatechange ||
461 !!this.onprogress;
462
463 this._subscriptions.push(RCTNetworking.addListener(
464 'didSendNetworkData',
465 (args) => this.__didUploadProgress(...args)
466 ));
467 this._subscriptions.push(RCTNetworking.addListener(
468 'didReceiveNetworkResponse',
469 (args) => this.__didReceiveResponse(...args)
470 ));
471 this._subscriptions.push(RCTNetworking.addListener(
472 'didReceiveNetworkData',
473 (args) => this.__didReceiveData(...args)
474 ));
475 this._subscriptions.push(RCTNetworking.addListener(
476 'didReceiveNetworkIncrementalData',
477 (args) => this.__didReceiveIncrementalData(...args)
478 ));
479 this._subscriptions.push(RCTNetworking.addListener(
480 'didReceiveNetworkDataProgress',
481 (args) => this.__didReceiveDataProgress(...args)
482 ));
483 this._subscriptions.push(RCTNetworking.addListener(
484 'didCompleteNetworkResponse',
485 (args) => this.__didCompleteResponse(...args)
486 ));
487
488 let nativeResponseType = 'text';
489 if (this._responseType === 'arraybuffer' || this._responseType === 'blob') {
490 nativeResponseType = 'base64';
491 }
492
493 invariant(this._method, 'Request method needs to be defined.');
494 invariant(this._url, 'Request URL needs to be defined.');
495 RCTNetworking.sendRequest(
496 this._method,
497 this._trackingName,
498 this._url,
499 this._headers,
500 data,
501 nativeResponseType,
502 incrementalEvents,
503 this.timeout,
504 this.__didCreateRequest.bind(this),
505 this.withCredentials
506 );
507 }
508

Callers 2

_uploadFunction · 0.95

Calls 10

__didUploadProgressMethod · 0.95
__didReceiveResponseMethod · 0.95
__didReceiveDataMethod · 0.95
__didCompleteResponseMethod · 0.95
invariantFunction · 0.85
pushMethod · 0.80
addListenerMethod · 0.45
sendRequestMethod · 0.45

Tested by

no test coverage detected