Liferay.Loader.define("commerce-organization-web@5.0.46/js/utils/fetch",["module","exports","require","frontend-js-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.fetchFromHeadless=function fetchFromHeadless(t,n={},r,s){return(0,o.fetch)(t,_objectSpread({headers:e},n)).then(handleFetchResponse).then((e=>handleResponseOk(e,r))).catch((e=>handleResponseNotOk(e,s)))},t.handleFetchResponse=handleFetchResponse,t.handleResponseOk=handleResponseOk,t.handleResponseNotOk=handleResponseNotOk;var o=n("frontend-js-web");function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e=new Headers({Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"});function handleFetchResponse(e){return e.json().then((t=>e.ok?Promise.resolve(t):Promise.reject(t))).catch((t=>e.ok?Promise.resolve(null):Promise.reject(_objectSpread(_objectSpread({},t),{},{title:t.title||t.status}))))}function handleResponseOk(e,t){return t&&(0,o.openToast)({message:t,type:"success"}),e}function handleResponseNotOk(e,t=!1){throw console.error(e),t&&(0,o.openToast)({message:e.title,type:"danger"}),e}}}));
//# sourceMappingURL=fetch.js.map