UNPKG

phx-react

Version:

PHX REACT

25 lines 855 B
import PHXFuncGetCookieSession from './getCookieSession'; async function PHXFetchAPI(url, options) { try { const cookieSession = PHXFuncGetCookieSession(); const { method, body } = options; const response = await fetch(url, { method, headers: { Authorization: 'Bearer' + ' ' + (cookieSession === null || cookieSession === void 0 ? void 0 : cookieSession.access_token), 'Content-Type': 'application/json', }, body, }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } return await response.json(); } catch (error) { console.error('Error calling API:', error); throw error; } } export default PHXFetchAPI; //# sourceMappingURL=serverQuery.js.map