mirror of
https://github.com/vercel/commerce.git
synced 2025-05-20 16:36:59 +00:00
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
|