Skip to content

Commit 7f6e093

Browse files
author
Asier Cidon
committed
Added https support with rejectUnauthorized disabled
1 parent 4a013a9 commit 7f6e093

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/infrastructure/postJump.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import axios from 'axios';
1+
import axios, { AxiosInstance } from 'axios';
2+
import https from 'https';
23
import { Jump } from '../domain/Jump';
34
import { ResponseBack } from '../domain/ResponseBack';
45

56
export const sentJump = async (
67
url: string,
78
data: Jump
8-
// calls: number,
9-
// callsInterval: number
109
): Promise<ResponseBack> => {
11-
// const timeout = async (ms: number) => {
12-
// return new Promise((resolve) => setTimeout(resolve, ms * 1000));
13-
// };
10+
// Define Axios Instance
11+
const instance: AxiosInstance = axios.create({
12+
httpsAgent: new https.Agent({
13+
rejectUnauthorized: false,
14+
}),
15+
});
1416

17+
// Define options with headers
1518
const options = {
1619
headers: {
1720
'Content-Type': 'application/json',
18-
'React-modifier': 'true'
19-
}
21+
'React-modifier': 'true',
22+
},
2023
};
2124

25+
// Execute Post
2226
try {
2327
let response: any;
24-
// for (let index = 0; index < calls; index++) {
25-
// await timeout(callsInterval);
26-
response = await axios.post(url, JSON.stringify(data), options);
27-
// }
28-
// Sent the last result
28+
response = await instance.post(url, JSON.stringify(data), options);
2929
return response.data;
3030
} catch (error) {
3131
console.log(error);

0 commit comments

Comments
 (0)