@useflagly/sdk-javascript 0.2.5 → 0.2.10
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/README.md +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -5
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare class FlaglyError extends Error {
|
|
|
19
19
|
constructor(statusCode: number, body: string);
|
|
20
20
|
get isSubscriptionError(): boolean;
|
|
21
21
|
get isUnauthorized(): boolean;
|
|
22
|
+
get isNetworkError(): boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare class UseFlaglyClient {
|
|
24
25
|
private baseUrl;
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,9 @@ class FlaglyError extends Error {
|
|
|
18
18
|
get isUnauthorized() {
|
|
19
19
|
return this.statusCode === 401;
|
|
20
20
|
}
|
|
21
|
+
get isNetworkError() {
|
|
22
|
+
return this.statusCode === 0;
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
exports.FlaglyError = FlaglyError;
|
|
23
26
|
const DEFAULT_BASE_URL = 'https://api.useflagly.com.br';
|
|
@@ -38,11 +41,17 @@ class UseFlaglyClient {
|
|
|
38
41
|
return h;
|
|
39
42
|
}
|
|
40
43
|
async request(path, method = 'GET', body, env) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
let res;
|
|
45
|
+
try {
|
|
46
|
+
res = await (0, cross_fetch_1.default)(this.baseUrl + path, {
|
|
47
|
+
method,
|
|
48
|
+
headers: this.headers(env),
|
|
49
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
throw new FlaglyError(0, err instanceof Error ? err.message : String(err));
|
|
54
|
+
}
|
|
46
55
|
if (res.status === 204)
|
|
47
56
|
return null;
|
|
48
57
|
const text = await res.text();
|