Advertisement
darth-vader

Untitled

Jan 27th, 2021
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get(url) {
  2. return new Promise((r, rj) => {
  3. var xhr  = new XMLHttpRequest()
  4. xhr.open('GET', url, true)
  5. xhr.onload = function () {
  6.     var data = JSON.parse(xhr.responseText);
  7.     if (xhr.readyState == 4 && xhr.status == "200") {
  8.         r(data);
  9.     } else {
  10.         rj(data);
  11.     }
  12. }
  13. xhr.send(null);
  14. });
  15. }
  16. function del(id) {
  17. var url = "https://signing.dev.jinjer.info/api/core/contracts/";
  18. var xhr = new XMLHttpRequest();
  19. xhr.open("DELETE", url+id, true);
  20. xhr.onload = function () {
  21.     var data = JSON.parse(xhr.responseText);
  22.     if (xhr.readyState == 4 && xhr.status == "200") {
  23.         console.table(data);
  24.     } else {
  25.         console.error(data);
  26.     }
  27. }
  28. xhr.send(null);
  29. }
  30. function delay(t){return new Promise(r => setTimeout(r, t));}
  31. (async () => {
  32.     const data = await get('https://signing.dev.jinjer.info/api/core/contracts')
  33.     for(let c of data.content) {
  34.         await del(c.id)
  35.         await delay(100)
  36.     }
  37. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement