Skip to content

Commit

Permalink
fix: catch error from ensureWPApiSettings
Browse files Browse the repository at this point in the history
error thrown in administration interface
due to  not being (and should not be) available.
  • Loading branch information
thorbrink committed Sep 25, 2023
1 parent 4ec246c commit 3291510
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions source/js/modularity.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ if (!parent.Modularity) {
}

(function () {
ensureWPApiSettings();

const { root, nonce } = window.wpApiSettings;
const fetch = window.fetch.bind(window);
const endpoints = ModulesRestAPIEndpoints(root);
const restAPI = new ModulesRestAPI(fetch, endpoints, nonce);

new ModuleRefresher(restAPI).refreshModules();
try {
ensureWPApiSettings();

const { root, nonce } = window.wpApiSettings;
const fetch = window.fetch.bind(window);
const endpoints = ModulesRestAPIEndpoints(root);
const restAPI = new ModulesRestAPI(fetch, endpoints, nonce);

new ModuleRefresher(restAPI).refreshModules();
} catch (error) {
console.warn(error);
}
})();

0 comments on commit 3291510

Please sign in to comment.