add graphql
parent
7e69f674ce
commit
fd368c1798
|
@ -0,0 +1,25 @@
|
|||
|
||||
export default async function graphql(query = '', variables = {}, token = '',) {
|
||||
|
||||
const response = await fetch(`https://api.adhorizonintl.com/graphql`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query,
|
||||
variables,
|
||||
}),
|
||||
cache:"no-store"
|
||||
});
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
if (json.errors) {
|
||||
console.error(json.errors);
|
||||
throw new Error('Failed to fetch GraphQL data');
|
||||
}
|
||||
|
||||
return json.data ;
|
||||
}
|
Loading…
Reference in New Issue