mirror of
https://github.com/vercel/commerce.git
synced 2025-03-16 23:42:32 +00:00
* Add ordercloud provider * Fix provider errors * Make submit checkout optional * Make submit checkout optional * Remove nullables when creating endpoint type * Update readme * Log checkout error * Log error * Save token to cookie * Update fetch rest * Use token at checkout Co-authored-by: Luis Alvarez <luis@vercel.com>
18 lines
417 B
TypeScript
18 lines
417 B
TypeScript
import { Fetcher } from '@commerce/utils/types'
|
|
|
|
const clientFetcher: Fetcher = async ({ method, url, body }) => {
|
|
const response = await fetch(url!, {
|
|
method,
|
|
body: body ? JSON.stringify(body) : undefined,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
})
|
|
.then((response) => response.json())
|
|
.then((response) => response.data)
|
|
|
|
return response
|
|
}
|
|
|
|
export default clientFetcher
|