add graphql

main
Amir Hossein Moghiseh 2025-02-17 04:57:46 +03:30
parent 7e69f674ce
commit fd368c1798
1 changed files with 25 additions and 0 deletions

View File

@ -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 ;
}