Apply prettier over all files

This commit is contained in:
Luis Alvarez
2020-10-01 20:40:40 -05:00
parent 2314ad760a
commit 0ef6449aff
72 changed files with 648 additions and 652 deletions

View File

@@ -2,38 +2,38 @@ import {
CommerceProvider as CoreCommerceProvider,
Connector,
useCommerce as useCoreCommerce,
} from 'lib/commerce';
} from 'lib/commerce'
async function getText(res: Response) {
try {
return (await res.text()) || res.statusText;
return (await res.text()) || res.statusText
} catch (error) {
return res.statusText;
return res.statusText
}
}
async function getError(res: Response) {
if (res.headers.get('Content-Type')?.includes('application/json')) {
const data = await res.json();
return data.errors[0];
const data = await res.json()
return data.errors[0]
}
return { message: await getText(res) };
return { message: await getText(res) }
}
async function fetcher(url: string, query: string) {
const res = await fetch(url);
const res = await fetch(url)
if (res.ok) {
return res.json();
return res.json()
}
throw await getError(res);
throw await getError(res)
}
export const bigcommerce: Connector = {
locale: 'en-us',
fetcher,
};
}
// TODO: The connector should be extendable when a developer is using it
export function CommerceProvider({ children }) {
@@ -41,7 +41,7 @@ export function CommerceProvider({ children }) {
<CoreCommerceProvider connector={bigcommerce}>
{children}
</CoreCommerceProvider>
);
)
}
export const useCommerce = () => useCoreCommerce();
export const useCommerce = () => useCoreCommerce()