@textback/notification-widget
Version:
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
21 lines (15 loc) • 499 B
JavaScript
import apiErrorHandler from './apiErrorHandler.js';
const cache = {};
export default function loadConfig(widgetId, apiPath) {
if (!widgetId) {
return Promise.reject('Widget id required');
}
if (cache[widgetId]) {
return cache[widgetId];
}
const loadingPromise = fetch(`${apiPath}/endUserNotifications/widgets/${widgetId}`).then(apiErrorHandler);
loadingPromise.then(() => {
cache[widgetId] = loadingPromise;
});
return loadingPromise;
};