glitch-javascript-sdk 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ import { Users } from "./api";
5
5
  import { Events } from "./api";
6
6
  import { Teams } from "./api";
7
7
  import { Waitlists } from "./api";
8
+ import Requests from "./util/Requests";
9
+ import Parser from "./util/Parser";
8
10
  declare class Glitch {
9
11
  static config: {
10
12
  Config: typeof Config;
@@ -17,5 +19,9 @@ declare class Glitch {
17
19
  Teams: typeof Teams;
18
20
  Waitlists: typeof Waitlists;
19
21
  };
22
+ static util: {
23
+ Requests: typeof Requests;
24
+ Parser: typeof Parser;
25
+ };
20
26
  }
21
27
  export default Glitch;
package/dist/esm/index.js CHANGED
@@ -31470,6 +31470,29 @@ var Waitlists = /** @class */ (function () {
31470
31470
  return Waitlists;
31471
31471
  }());
31472
31472
 
31473
+ var Parser = /** @class */ (function () {
31474
+ function Parser() {
31475
+ }
31476
+ /**
31477
+ * To be used inside a catch close, this function will parse out any JSON in a error response from the api.
31478
+ *
31479
+ * @param error The Error object from the catch clause
31480
+ *
31481
+ * @returns Either returns a JSON object or false.
31482
+ */
31483
+ Parser.parseJSONFromError = function (error) {
31484
+ var errorString = error.toString();
31485
+ errorString = errorString.replace('Error: ', '');
31486
+ try {
31487
+ return JSON.parse(errorString);
31488
+ }
31489
+ catch (e) {
31490
+ return false;
31491
+ }
31492
+ };
31493
+ return Parser;
31494
+ }());
31495
+
31473
31496
  //Configuration
31474
31497
  var Glitch = /** @class */ (function () {
31475
31498
  function Glitch() {
@@ -31485,6 +31508,10 @@ var Glitch = /** @class */ (function () {
31485
31508
  Teams: Teams,
31486
31509
  Waitlists: Waitlists
31487
31510
  };
31511
+ Glitch.util = {
31512
+ Requests: Requests,
31513
+ Parser: Parser
31514
+ };
31488
31515
  return Glitch;
31489
31516
  }());
31490
31517