From 895aae5b52ade4615e71c3e7cbb52dd601149e5f Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 30 Mar 2020 10:07:28 -0600 Subject: [PATCH 1/2] Add fetchFunction binding appropriate version of fetch for ems client --- src/legacy/ui/public/vis/map/service_settings.js | 1 + x-pack/legacy/plugins/maps/server/routes.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/legacy/ui/public/vis/map/service_settings.js b/src/legacy/ui/public/vis/map/service_settings.js index 9f3d21831e3da..d26730266cd57 100644 --- a/src/legacy/ui/public/vis/map/service_settings.js +++ b/src/legacy/ui/public/vis/map/service_settings.js @@ -53,6 +53,7 @@ uiModules tileApiUrl: mapConfig.emsTileApiUrl, htmlSanitizer: $sanitize, landingPageUrl: mapConfig.emsLandingPageUrl, + fetchFunction: fetch, }); } diff --git a/x-pack/legacy/plugins/maps/server/routes.js b/x-pack/legacy/plugins/maps/server/routes.js index 6aacfdc41aeea..20e022001577a 100644 --- a/x-pack/legacy/plugins/maps/server/routes.js +++ b/x-pack/legacy/plugins/maps/server/routes.js @@ -44,6 +44,7 @@ export function initRoutes(server, licenseUid) { fileApiUrl: mapConfig.emsFileApiUrl, tileApiUrl: mapConfig.emsTileApiUrl, landingPageUrl: mapConfig.emsLandingPageUrl, + fetchFunction: fetch, }); emsClient.addQueryParams({ license: licenseUid }); } else { From 935d24bb09d5985ba34cb84227af689e8bf60615 Mon Sep 17 00:00:00 2001 From: Aaron Caldwell Date: Mon, 30 Mar 2020 14:55:03 -0600 Subject: [PATCH 2/2] Wrap standard window fetch prior to passing to ems-client --- src/legacy/ui/public/vis/map/service_settings.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/legacy/ui/public/vis/map/service_settings.js b/src/legacy/ui/public/vis/map/service_settings.js index d26730266cd57..a014aeb182c67 100644 --- a/src/legacy/ui/public/vis/map/service_settings.js +++ b/src/legacy/ui/public/vis/map/service_settings.js @@ -53,7 +53,10 @@ uiModules tileApiUrl: mapConfig.emsTileApiUrl, htmlSanitizer: $sanitize, landingPageUrl: mapConfig.emsLandingPageUrl, - fetchFunction: fetch, + // Wrap to avoid errors passing window fetch + fetchFunction: function(...args) { + return fetch(...args); + }, }); }