@akc42/app-utils 3.3.2 → 3.3.3
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/package.json +1 -1
- package/post-api.js +5 -1
package/package.json
CHANGED
package/post-api.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
export default async function api(url, params, blob, signal) {
|
|
23
|
+
const address = '/api/' + url;
|
|
23
24
|
const options = {
|
|
24
25
|
credentials: 'same-origin',
|
|
25
26
|
method: 'post',
|
|
@@ -28,11 +29,14 @@ export default async function api(url, params, blob, signal) {
|
|
|
28
29
|
}),
|
|
29
30
|
body: JSON.stringify(params ?? {})
|
|
30
31
|
};
|
|
32
|
+
performance.mark('fetchapi', { detail: `${address} params: ${options.body}` })
|
|
31
33
|
if (signal) options.signal = signal;
|
|
32
34
|
let text;
|
|
33
35
|
try {
|
|
34
|
-
const response = await window.fetch(
|
|
36
|
+
const response = await window.fetch(address, options);
|
|
35
37
|
if (!response.ok) throw new CustomEvent('api-error', {composed: true, bubbles: true , detail:response.status});
|
|
38
|
+
performance.mark('fetchdone', {detail: address});
|
|
39
|
+
performance.measure('apicalltime',{startMark: 'fetchapi', endMark:'fetchdone', detail: address});
|
|
36
40
|
if (blob) {
|
|
37
41
|
text = '---502---'; //Simulate a 502 (bad gateway) incase there is an error in following.
|
|
38
42
|
const b = await response.blob();
|