Skip to content

Commit 95da72e

Browse files
committed
CLDR-18518 cldrAjax: re-export window.fetch
1 parent 3bb1e2a commit 95da72e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tools/cldr-apps/js/src/esm/cldrAjax.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ const SLASH_API_SLASH = "/api/";
1313
* Call the standard js fetch function, possibly with additional handling suitable
1414
* for Survey Tool such as setting session headers and debugging
1515
*
16-
* Session headers are automatically added
16+
* Session headers are automatically added.
17+
* Only use this for calling back to the Survey Tool, otherwise session headers will leak.
1718
*
1819
* @param {String} resource the url or other resource, or Request object
1920
* @param {Object} init an object containing any custom settings for the request
20-
* @returns a Promise that resolves to a Response object
21+
* @returns {Promise<Response>}
2122
*/
2223
function doFetch(resource, init) {
2324
if (ST_AJAX_DEBUG) {
@@ -27,6 +28,12 @@ function doFetch(resource, init) {
2728
return fetch(resource, init);
2829
}
2930

31+
/**
32+
* re-exported global fetch, in case we want to do any logging or customization.
33+
* Use this for non-SurveyTool (external) queries
34+
*/
35+
const fetch = window.fetch;
36+
3037
/**
3138
* If the current user has a session id, add it to the fetch headers, creating
3239
* init and/or init.headers if not already defined
@@ -254,6 +261,7 @@ function isApiUrl(url) {
254261

255262
export {
256263
doFetch,
264+
fetch,
257265
handleFetchErrors,
258266
makeApiUrl,
259267
makePostData,

tools/cldr-apps/js/src/esm/cldrDeferHelp.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import { marked } from "./cldrMarked.mjs";
55
import * as cldrNotify from "./cldrNotify.mjs";
6+
import { fetch } from "./cldrAjax.mjs";
67

78
const defaultEndpoint = "https://dbpedia.org/sparql/";
89

0 commit comments

Comments
 (0)