(data: any)
| 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 |
no test coverage detected