|
1 | 1 |
|
2 | 2 | import CryptoJS from 'crypto-js'; |
3 | 3 |
|
| 4 | +import axios from 'axios'; |
4 | 5 |
|
5 | 6 |
|
6 | 7 | const shuffleCharacterAt = (content, rNumber) => { |
@@ -36,31 +37,14 @@ export const encrypt = (content, password) => escape(CryptoJS.AES.encrypt(conten |
36 | 37 | export const decrypt = (content, password) => CryptoJS.AES.decrypt(unescape(content), password).toString(CryptoJS.enc.Utf8); |
37 | 38 |
|
38 | 39 | export const basicGetURL = (url, onSuccess, onError) => { |
39 | | - let request = new XMLHttpRequest(); |
40 | | - request.ontimeout = (e) => { |
41 | | - console.warn(" socket-server-url-timeout "); |
42 | | - onError('socket-server-url-timeout'); |
43 | | - }; |
44 | | - request.onreadystatechange = (e) => { |
45 | | - if (request.readyState !== 4) { |
46 | | - return; |
47 | | - } |
48 | | - if (request.status === 200) { |
49 | | - try { |
50 | | - onSuccess(JSON.parse(request.responseText)); |
51 | | - } |
52 | | - catch (error) { |
53 | | - onError("invalid processing the server response:" + error); |
54 | | - console.log("server response:" + request.responseText); |
55 | | - } |
56 | | - } else { |
57 | | - onError('socket-server-url-status:' + request.status); |
58 | | - } |
59 | | - }; |
60 | | - |
61 | | - request.open('GET', url, true); |
| 40 | + axios.get(url).then(response=>{ |
| 41 | + |
| 42 | + onSuccess(response.data); |
| 43 | + }).catch(error =>{ |
| 44 | + onError('socket-server-url-timeout'); |
| 45 | + }); |
62 | 46 |
|
63 | | - request.send(); |
| 47 | + |
64 | 48 | }; |
65 | 49 |
|
66 | 50 | export const buildOptionsFromInputCodedata = (connector, codedata, options) => { |
|
0 commit comments