☠️ RESET for v2

This commit is contained in:
2021-09-14 13:00:12 +02:00
parent 511b0c85e5
commit bdbf511a75
124 changed files with 1612 additions and 11094 deletions

27
src/utils/api.ts Normal file
View File

@@ -0,0 +1,27 @@
const apiURL: string = process.env.NODE_ENV === 'development' ? `${import.meta.env.VITE_API_GRAPHQL_URL_DEV}` : `${import.meta.env.VITE_API_GRAPHQL_URL_PROD}`
/**
* Fetch data from Directus API
*/
export const fetchAPI = async (query: string) => {
try {
const res = await fetch(apiURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${import.meta.env.VITE_API_TOKEN}`,
},
body: JSON.stringify({
query
})
})
if (res.ok) {
const data = await res.json()
return data
}
} catch (error) {
console.error(error)
}
}