mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
24 lines
507 B
TypeScript
24 lines
507 B
TypeScript
interface requestProps {
|
|
query: string
|
|
variables: any
|
|
}
|
|
const request = async ({query, variables}: requestProps) => {
|
|
|
|
const data = await fetch('http://localhost:5000/shop-api', {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
credentials: 'include',
|
|
body: JSON.stringify({ query: query, variables: variables })
|
|
})
|
|
|
|
if (data.status === 200) {
|
|
const response = await data.json()
|
|
return response
|
|
}
|
|
|
|
return {
|
|
error: true
|
|
}
|
|
}
|
|
|
|
export default request |