@symbo.ls/fetch 2.11.132 → 2.11.164
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/cjs/index.js +7 -4
- package/index.js +6 -10
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -39,13 +39,13 @@ var globals = __toESM(require("@domql/globals"), 1);
|
|
|
39
39
|
const { overwriteDeep, deepDestringify } = utils;
|
|
40
40
|
const { window } = globals;
|
|
41
41
|
const IS_DEVELOPMENT = window && window.location ? window.location.host.includes("dev.") || window.location.host.includes("symbo.ls") : true;
|
|
42
|
-
const SERVER_URL = IS_DEVELOPMENT ? "localhost:13335" : "https://api.symbols.
|
|
42
|
+
const SERVER_URL = IS_DEVELOPMENT ? "http://localhost:13335/" : "https://api.symbols.app/";
|
|
43
43
|
const defaultOptions = {
|
|
44
44
|
endpoint: SERVER_URL
|
|
45
45
|
};
|
|
46
46
|
const fetch = globalThis.fetch;
|
|
47
47
|
const fetchRemote = async (key, options = defaultOptions) => {
|
|
48
|
-
const baseUrl = options.endpoint
|
|
48
|
+
const baseUrl = options.endpoint || SERVER_URL;
|
|
49
49
|
const route = options.serviceRoute ? utils.isArray(options.serviceRoute) ? options.serviceRoute.map((v) => v.toLowerCase()).join(",") : options.serviceRoute : "";
|
|
50
50
|
let response;
|
|
51
51
|
try {
|
|
@@ -53,10 +53,13 @@ const fetchRemote = async (key, options = defaultOptions) => {
|
|
|
53
53
|
method: "GET",
|
|
54
54
|
headers: { "Content-Type": "application/json", "X-AppKey": key }
|
|
55
55
|
});
|
|
56
|
+
return await response.json();
|
|
56
57
|
} catch (e) {
|
|
57
|
-
|
|
58
|
+
if (utils.isFunction(options.onError))
|
|
59
|
+
return options.onError(e);
|
|
60
|
+
else
|
|
61
|
+
console.error(e);
|
|
58
62
|
}
|
|
59
|
-
return await response.json();
|
|
60
63
|
};
|
|
61
64
|
const fetchProject = async (key, options) => {
|
|
62
65
|
const { editor } = options;
|
package/index.js
CHANGED
|
@@ -11,8 +11,8 @@ const IS_DEVELOPMENT = window && window.location
|
|
|
11
11
|
: process.env.NODE_ENV === 'development'
|
|
12
12
|
|
|
13
13
|
const SERVER_URL = IS_DEVELOPMENT
|
|
14
|
-
? 'localhost:13335'
|
|
15
|
-
: 'https://api.symbols.
|
|
14
|
+
? 'http://localhost:13335/'
|
|
15
|
+
: 'https://api.symbols.app/'
|
|
16
16
|
|
|
17
17
|
const defaultOptions = {
|
|
18
18
|
endpoint: SERVER_URL
|
|
@@ -21,11 +21,7 @@ const defaultOptions = {
|
|
|
21
21
|
export const fetch = globalThis.fetch
|
|
22
22
|
|
|
23
23
|
export const fetchRemote = async (key, options = defaultOptions) => {
|
|
24
|
-
const baseUrl = options.endpoint
|
|
25
|
-
? options.endpoint.includes('http')
|
|
26
|
-
? options.endpoint
|
|
27
|
-
: `https://${options.endpoint}/`
|
|
28
|
-
: SERVER_URL
|
|
24
|
+
const baseUrl = options.endpoint || SERVER_URL
|
|
29
25
|
const route = options.serviceRoute
|
|
30
26
|
? utils.isArray(options.serviceRoute)
|
|
31
27
|
? options.serviceRoute.map(v => v.toLowerCase()).join(',')
|
|
@@ -38,11 +34,11 @@ export const fetchRemote = async (key, options = defaultOptions) => {
|
|
|
38
34
|
method: 'GET',
|
|
39
35
|
headers: { 'Content-Type': 'application/json', 'X-AppKey': key }
|
|
40
36
|
})
|
|
37
|
+
return await response.json()
|
|
41
38
|
} catch (e) {
|
|
42
|
-
|
|
39
|
+
if (utils.isFunction(options.onError)) return options.onError(e)
|
|
40
|
+
else console.error(e)
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
return await response.json()
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
export const fetchProject = async (key, options) => {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/fetch",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.164",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"gitHead": "
|
|
5
|
+
"gitHead": "943a48800e5959b8c1f15d5d8d49224565038c23",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "index.js",
|
|
8
8
|
"main": "index.js",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"build:cjs": "npx esbuild ./index.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
22
22
|
"build:iife": "npx esbuild ./index.js --target=es2020 --format=iife --outdir=dist/iife --bundle --minify",
|
|
23
23
|
"build": "yarn build:cjs && yarn copy:package:cjs",
|
|
24
|
-
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
24
|
+
"prepublish": "npx rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
}
|
|
26
26
|
}
|