Skip to content

Commit fd2cf4a

Browse files
committed
Merged in release/16.2.1 (pull request #84)
Release/16.2.1
2 parents fff5324 + 24374ab commit fd2cf4a

5 files changed

Lines changed: 225 additions & 214 deletions

File tree

Lines changed: 101 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,101 @@
1-
import axios from 'axios';
2-
import ApiConstants from './ApiConstants';
3-
4-
class AxiosNetworkTester {
5-
sendGetRequest() {
6-
axios
7-
.get(ApiConstants.GET_URL)
8-
.then(function (response) {
9-
alert('Request sent.');
10-
})
11-
.catch(function (error) {
12-
alert('Request error.');
13-
});
14-
}
15-
16-
sendPostRequest() {
17-
axios
18-
.post(ApiConstants.POST_URL, {
19-
firstParam: 'firstParam',
20-
secondParam: 'secondParam',
21-
})
22-
.then(function (response) {
23-
alert('Request sent.');
24-
})
25-
.catch(function (error) {
26-
alert('Request error.');
27-
});
28-
}
29-
30-
sendErrorRequest() {
31-
axios
32-
.get(ApiConstants.ERROR_URL)
33-
.then(function (response) {
34-
alert('Request sent.');
35-
})
36-
.catch(function (error) {
37-
alert('Request error.');
38-
});
39-
}
40-
41-
sendTimeoutRequest() {
42-
axios
43-
.post(
44-
ApiConstants.TIMEOUT_URL,
45-
{
46-
firstParam: 'firstParam',
47-
secondParam: 'secondParam',
48-
},
49-
{
50-
timeout: 1,
51-
},
52-
)
53-
.then(function (response) {
54-
alert('Request sent.');
55-
})
56-
.catch(function (error) {
57-
alert('Request error.');
58-
});
59-
}
60-
61-
postFileRequest() {
62-
const formData = new FormData();
63-
//formData.append('file', {uri: path, name: 'file.txt', type: 'text/plain'});
64-
formData.append('userId', 'xzy');
65-
66-
const config = {
67-
headers: {
68-
accept: 'application/json',
69-
},
70-
};
71-
72-
axios
73-
.post(ApiConstants.FILE_URL, formData, config)
74-
.then(function (response) {
75-
alert('Request sent.');
76-
})
77-
.catch(function (error) {
78-
alert('Request error.');
79-
});
80-
}
81-
82-
getImageRequest() {
83-
axios
84-
.get(ApiConstants.IMAGE_URL, {
85-
responseType: 'blob',
86-
})
87-
.then(function (response) {
88-
alert('Request sent.');
89-
})
90-
.catch(function (error) {
91-
alert('Request error.');
92-
});
93-
}
94-
}
95-
96-
export default AxiosNetworkTester;
1+
import axios from 'axios';
2+
import ApiConstants from './ApiConstants';
3+
4+
class AxiosNetworkTester {
5+
sendGetRequest() {
6+
axios
7+
.get(ApiConstants.GET_URL, {
8+
headers: {
9+
'number-header': 100,
10+
'array-header': ['hello', 'world'],
11+
},
12+
})
13+
.then(function (response) {
14+
alert('Request sent.');
15+
})
16+
.catch(function (error) {
17+
alert('Request error.');
18+
});
19+
}
20+
21+
sendPostRequest() {
22+
axios
23+
.post(ApiConstants.POST_URL, {
24+
firstParam: 'firstParam',
25+
secondParam: 'secondParam',
26+
})
27+
.then(function (response) {
28+
alert('Request sent.');
29+
})
30+
.catch(function (error) {
31+
alert('Request error.');
32+
});
33+
}
34+
35+
sendErrorRequest() {
36+
axios
37+
.get(ApiConstants.ERROR_URL)
38+
.then(function (response) {
39+
alert('Request sent.');
40+
})
41+
.catch(function (error) {
42+
alert('Request error.');
43+
});
44+
}
45+
46+
sendTimeoutRequest() {
47+
axios
48+
.post(
49+
ApiConstants.TIMEOUT_URL,
50+
{
51+
firstParam: 'firstParam',
52+
secondParam: 'secondParam',
53+
},
54+
{
55+
timeout: 1,
56+
},
57+
)
58+
.then(function (response) {
59+
alert('Request sent.');
60+
})
61+
.catch(function (error) {
62+
alert('Request error.');
63+
});
64+
}
65+
66+
postFileRequest() {
67+
const formData = new FormData();
68+
//formData.append('file', {uri: path, name: 'file.txt', type: 'text/plain'});
69+
formData.append('userId', 'xzy');
70+
71+
const config = {
72+
headers: {
73+
accept: 'application/json',
74+
},
75+
};
76+
77+
axios
78+
.post(ApiConstants.FILE_URL, formData, config)
79+
.then(function (response) {
80+
alert('Request sent.');
81+
})
82+
.catch(function (error) {
83+
alert('Request error.');
84+
});
85+
}
86+
87+
getImageRequest() {
88+
axios
89+
.get(ApiConstants.IMAGE_URL, {
90+
responseType: 'blob',
91+
})
92+
.then(function (response) {
93+
alert('Request sent.');
94+
})
95+
.catch(function (error) {
96+
alert('Request error.');
97+
});
98+
}
99+
}
100+
101+
export default AxiosNetworkTester;
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
import ApiConstants from './ApiConstants';
2-
3-
class FetchNetworkTester {
4-
sendGetRequest() {
5-
fetch(ApiConstants.GET_URL, {
6-
method: 'GET',
7-
})
8-
.then((res) => {
9-
alert('Request sent.');
10-
})
11-
.catch((error) => {
12-
alert('Request error.');
13-
});
14-
}
15-
16-
sendPostRequest() {
17-
fetch(ApiConstants.POST_URL, {
18-
method: 'POST',
19-
headers: {
20-
Accept: 'application/json',
21-
'Content-Type': 'application/json',
22-
},
23-
body: JSON.stringify({
24-
firstParam: 'firstParam',
25-
secondParam: 'secondParam',
26-
}),
27-
})
28-
.then((res) => {
29-
alert('Request sent.');
30-
})
31-
.catch((error) => {
32-
alert('Request error.');
33-
});
34-
}
35-
36-
sendErrorRequest() {
37-
fetch(ApiConstants.ERROR_URL, {
38-
method: 'GET',
39-
})
40-
.then((res) => {
41-
alert('Request sent.');
42-
})
43-
.catch((error) => {
44-
alert('Request error.');
45-
});
46-
}
47-
48-
sendTimeoutRequest() {
49-
alert('Not supported for test.');
50-
}
51-
52-
postFileRequest() {
53-
const formData = new FormData();
54-
//formData.append('file', {uri: path, name: 'file.txt', type: 'text/plain'});
55-
formData.append('userId', 'xzy');
56-
57-
fetch(ApiConstants.FILE_URL, {
58-
body: formData,
59-
headers: {
60-
'Content-Type': 'multipart/form-data',
61-
Accept: 'application/json',
62-
},
63-
method: 'POST',
64-
})
65-
.then((res) => {
66-
alert('Request sent.');
67-
})
68-
.catch((error) => {
69-
console.log(error);
70-
alert('Request error.');
71-
});
72-
}
73-
74-
getImageRequest() {
75-
fetch(ApiConstants.IMAGE_URL, {
76-
method: 'GET',
77-
})
78-
.then((res) => {
79-
alert('Request sent.');
80-
})
81-
.catch((error) => {
82-
alert('Request error.');
83-
});
84-
}
85-
}
86-
87-
export default FetchNetworkTester;
1+
import ApiConstants from './ApiConstants';
2+
3+
class FetchNetworkTester {
4+
sendGetRequest() {
5+
fetch(ApiConstants.GET_URL, {
6+
method: 'GET',
7+
})
8+
.then(res => {
9+
alert('Request sent.');
10+
})
11+
.catch(error => {
12+
alert('Request error.');
13+
});
14+
}
15+
16+
sendPostRequest() {
17+
fetch(ApiConstants.POST_URL, {
18+
method: 'POST',
19+
headers: {
20+
Accept: 'application/json',
21+
'Content-Type': 'application/json',
22+
},
23+
body: JSON.stringify({
24+
firstParam: 'firstParam',
25+
secondParam: 'secondParam',
26+
}),
27+
})
28+
.then(res => {
29+
alert('Request sent.');
30+
})
31+
.catch(error => {
32+
alert('Request error.');
33+
});
34+
}
35+
36+
sendErrorRequest() {
37+
fetch(ApiConstants.ERROR_URL, {
38+
method: 'GET',
39+
})
40+
.then(res => {
41+
alert('Request sent.');
42+
})
43+
.catch(error => {
44+
alert('Request error.');
45+
});
46+
}
47+
48+
sendTimeoutRequest() {
49+
alert('Not supported for test.');
50+
}
51+
52+
postFileRequest() {
53+
const formData = new FormData();
54+
//formData.append('file', {uri: path, name: 'file.txt', type: 'text/plain'});
55+
formData.append('userId', 'xzy');
56+
57+
fetch(ApiConstants.FILE_URL, {
58+
body: formData,
59+
headers: {
60+
'Content-Type': 'multipart/form-data',
61+
Accept: 'application/json',
62+
},
63+
method: 'POST',
64+
})
65+
.then(res => {
66+
alert('Request sent.');
67+
})
68+
.catch(error => {
69+
console.log(error);
70+
alert('Request error.');
71+
});
72+
}
73+
74+
getImageRequest() {
75+
fetch(ApiConstants.IMAGE_URL, {
76+
method: 'GET',
77+
})
78+
.then(res => {
79+
alert('Request sent.');
80+
})
81+
.catch(error => {
82+
alert('Request error.');
83+
});
84+
}
85+
}
86+
87+
export default FetchNetworkTester;

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ declare module "react-native-shake" {
180180
setRequestBody: (requestBody: string) => NetworkRequestBuilder;
181181
getResponseBody: () => string;
182182
setResponseBody: (responseBody: string) => NetworkRequestBuilder;
183-
getRequestHeaders: () => object;
184-
setRequestHeaders: (requestHeaders: object) => NetworkRequestBuilder;
185-
getResponseHeaders: () => object;
186-
setResponseHeaders: (responseHeaders: object) => NetworkRequestBuilder;
183+
getRequestHeaders: () => { [key: string]: string };
184+
setRequestHeaders: (requestHeaders: { [key: string]: string }) => NetworkRequestBuilder;
185+
getResponseHeaders: () => { [key: string]: string };
186+
setResponseHeaders: (responseHeaders: { [key: string]: string }) => NetworkRequestBuilder;
187187
getStatusCode: () => string;
188188
setStatusCode: (statusCode: string) => NetworkRequestBuilder;
189189
getDuration: () => string;

0 commit comments

Comments
 (0)