diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-07-14 16:59:46 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-07-14 16:59:46 +0300 |
| commit | 4d13762c095d650687de64816c589be25b56daa0 (patch) | |
| tree | 17de451178a15cdf97bcef00d89ab6d8af3adad0 /javascript | |
| parent | 4e0e2063e7b0141099b36adfc537e98f3b667695 (diff) | |
| download | linkeysearch-4d13762c095d650687de64816c589be25b56daa0.tar.gz linkeysearch-4d13762c095d650687de64816c589be25b56daa0.tar.bz2 linkeysearch-4d13762c095d650687de64816c589be25b56daa0.zip | |
unrelated scripts (sorry)
Diffstat (limited to 'javascript')
| -rw-r--r-- | javascript/unrelated/prom.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/javascript/unrelated/prom.js b/javascript/unrelated/prom.js new file mode 100644 index 0000000..f935dba --- /dev/null +++ b/javascript/unrelated/prom.js @@ -0,0 +1,61 @@ +// npm install xhr2 +var XMLHttpRequest = require('xhr2'); + +const get = url => { + return new Promise( (resolve, reject) => { + + var req = new XMLHttpRequest(); + req.open('GET', url); + + req.onload = function() { + // This is called even on 404 etc + // so check the status + if (req.status == 200) { + resolve(req.response); + + } else { + reject(Error(req.statusText)); + } + + }; + + req.onerror = function() { + reject(Error("Network Error... "+ url)); + }; + + // Make the request + req.send(); + + }); + +}; + + + +// var u1 = 'https://pokeapi.co/api/v2/pokemon?limit=5'; +// var u2 = 'https://pokeapi.co/api/v2/pokemon?limit=7'; + +var u1 = 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-keywords.json'; +var u2 = 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json'; + +/** --- + get(u1) + .then( + (result) => { + console.log(result); + }, + (error) => { + console.log(error); + } + ); +*/ + +p1 = get(u1); +p2 = get(u2); + +Promise.all([p1, p2]) +.then( + (result) => console.log(result), + (error) => console.log(error) +); + |
