Skip to content

Commit c8cefc9

Browse files
huntiefacebook-github-bot
authored andcommitted
Fix outdated XHRExampleBinaryUpload example (#54803)
Summary: The XMLHttpRequest `multipart/form-data` example in RNTester was referencing the `http://ptsv2.com/` test service, which no longer exists. Update this to `https://ptsv3.com/`. Changelog: [Internal] Differential Revision: D88493638
1 parent c800503 commit c8cefc9

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

packages/rn-tester/js/examples/XHR/XHRExampleBinaryUpload.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
import RNTesterText from '../../components/RNTesterText';
1414
import RNTOption from '../../components/RNTOption';
1515
import React from 'react';
16-
import {
17-
Alert,
18-
Linking,
19-
StyleSheet,
20-
Text,
21-
TouchableHighlight,
22-
View,
23-
} from 'react-native';
16+
import {Alert, StyleSheet, Text, TouchableHighlight, View} from 'react-native';
2417

2518
const BINARY_TYPES = {
2619
String,
@@ -62,17 +55,12 @@ class XHRExampleBinaryUpload extends React.Component<{...}, $FlowFixMe> {
6255
Alert.alert('Upload failed', 'No response payload.');
6356
return;
6457
}
65-
const index = xhr.responseText.indexOf(
66-
'http://ptsv2.com/t/react-native/d/',
67-
);
68-
if (index === -1) {
58+
const {status} = JSON.parse(xhr.responseText);
59+
if (status !== 'success') {
6960
Alert.alert('Upload failed', 'Invalid response payload.');
7061
return;
7162
}
72-
const url = xhr.responseText.slice(index).split('\n')[0];
73-
console.log('Upload successful: ' + url);
74-
// $FlowFixMe[unused-promise]
75-
Linking.openURL(url);
63+
Alert.alert('Upload successful: https://ptsv3.com/react-native');
7664
}
7765

7866
state: $FlowFixMe | {type: 'Uint8Array'} = {
@@ -81,7 +69,7 @@ class XHRExampleBinaryUpload extends React.Component<{...}, $FlowFixMe> {
8169

8270
_upload = () => {
8371
const xhr = new XMLHttpRequest();
84-
xhr.open('POST', 'http://ptsv2.com/t/react-native/post');
72+
xhr.open('POST', 'https://ptsv3.com/t/react-native/post');
8573
xhr.onload = () => XHRExampleBinaryUpload.handlePostTestServerUpload(xhr);
8674
xhr.setRequestHeader('Content-Type', 'text/plain');
8775

0 commit comments

Comments
 (0)