@brianbuie/node-kit 0.2.1 → 0.2.2

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.
package/.dist/Fetcher.js CHANGED
@@ -26,7 +26,7 @@ export class Fetcher {
26
26
  if (val === undefined)
27
27
  return;
28
28
  if (Array.isArray(val)) {
29
- val.forEach(v => {
29
+ val.forEach((v) => {
30
30
  params.push([key, `${v}`]);
31
31
  });
32
32
  }
@@ -73,7 +73,7 @@ export class Fetcher {
73
73
  // Rebuild request on every attempt to reset AbortSignal.timeout
74
74
  const [req] = this.buildRequest(route, opts);
75
75
  const res = await fetch(req)
76
- .then(r => {
76
+ .then((r) => {
77
77
  if (!r.ok)
78
78
  throw new Error(r.statusText);
79
79
  return r;
@@ -82,7 +82,10 @@ export class Fetcher {
82
82
  if (attempt < maxAttempts) {
83
83
  const wait = attempt * 3000;
84
84
  console.warn(`${req.method} ${req.url} (attempt ${attempt} of ${maxAttempts})`, error);
85
- await new Promise(resolve => setTimeout(resolve, wait));
85
+ await new Promise((resolve) => setTimeout(resolve, wait));
86
+ }
87
+ else {
88
+ throw new Error(error);
86
89
  }
87
90
  });
88
91
  if (res)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brianbuie/node-kit",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "license": "ISC",
5
5
  "repository": {
6
6
  "type": "git",
package/src/Fetcher.ts CHANGED
@@ -43,7 +43,7 @@ export class Fetcher {
43
43
  Object.entries(mergedOptions.query || {}).forEach(([key, val]) => {
44
44
  if (val === undefined) return;
45
45
  if (Array.isArray(val)) {
46
- val.forEach(v => {
46
+ val.forEach((v) => {
47
47
  params.push([key, `${v}`]);
48
48
  });
49
49
  } else {
@@ -91,15 +91,17 @@ export class Fetcher {
91
91
  // Rebuild request on every attempt to reset AbortSignal.timeout
92
92
  const [req] = this.buildRequest(route, opts);
93
93
  const res = await fetch(req)
94
- .then(r => {
94
+ .then((r) => {
95
95
  if (!r.ok) throw new Error(r.statusText);
96
96
  return r;
97
97
  })
98
- .catch(async error => {
98
+ .catch(async (error) => {
99
99
  if (attempt < maxAttempts) {
100
100
  const wait = attempt * 3000;
101
101
  console.warn(`${req.method} ${req.url} (attempt ${attempt} of ${maxAttempts})`, error);
102
- await new Promise(resolve => setTimeout(resolve, wait));
102
+ await new Promise((resolve) => setTimeout(resolve, wait));
103
+ } else {
104
+ throw new Error(error);
103
105
  }
104
106
  });
105
107
  if (res) return [res, req];