const createFetchClient = ({ baseURL, headers: baseHeaders = {} }) => { return async ({ method = 'GET', url, query = undefined, headers = {}, body = undefined, }) => { const theURL = new URL(url, baseURL) if (query) { theURL.search = new URLSearchParams(query).toString() } return fetch(theURL.toString(), { method, body, headers: { ...baseHeaders, ...headers, } }) } } export default createFetchClient