anilink-api-wrapper 1.17.0 → 1.17.1

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.
@@ -22,12 +22,31 @@ const sendRequest = (url, method, data, token) => __awaiter(void 0, void 0, void
22
22
  if (token !== null && token !== undefined && token !== '') {
23
23
  headers.Authorization = `Bearer ${token}`;
24
24
  }
25
- const response = yield (0, axios_1.default)({
26
- url,
27
- method,
28
- data,
29
- headers
30
- });
31
- return response.data;
25
+ try {
26
+ const response = yield (0, axios_1.default)({
27
+ url,
28
+ method,
29
+ data,
30
+ headers
31
+ });
32
+ return response.data;
33
+ }
34
+ catch (error) {
35
+ if (error.response) {
36
+ // The request was made and the server responded with a status code
37
+ // that falls out of the range of 2xx
38
+ throw error.response;
39
+ }
40
+ else if (error.request) {
41
+ // The request was made but no response was received
42
+ // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
43
+ // http.ClientRequest in node.js
44
+ throw error.request;
45
+ }
46
+ else {
47
+ // Something happened in setting up the request that triggered an Error
48
+ throw error.message;
49
+ }
50
+ }
32
51
  });
33
52
  exports.sendRequest = sendRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anilink-api-wrapper",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "Anilist API Wrapper",
5
5
  "main": "dist/AniLink.js",
6
6
  "scripts": {