lenix 1.1.2 → 1.2.0
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 +0 -3
- package/dist/fetch/index.d.ts +1 -0
- package/dist/fetch/index.js +11 -0
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const safeRequest: (domain: string, endpoint: string, request: RequestInit) => Promise<Response>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const safeRequest = async (domain, endpoint, request) => {
|
|
2
|
+
try {
|
|
3
|
+
return await fetch(`https://${domain}/${endpoint}`, request);
|
|
4
|
+
}
|
|
5
|
+
catch (error) {
|
|
6
|
+
throw new Error('An error occurred while making the request.', { cause: error });
|
|
7
|
+
}
|
|
8
|
+
finally {
|
|
9
|
+
console.log(`End of ${domain}${endpoint} request`);
|
|
10
|
+
}
|
|
11
|
+
};
|