1234567891011121314151617181920212223 |
- const getGQL = (url) => (query, variables) => {
- return fetch(url, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- // 'Accept' : 'application/json',
- ...(localStorage.authToken
- ? { Authorization: "Bearer " + localStorage.authToken }
- : {}),
- },
- body: JSON.stringify({ query, variables }),
- })
- .then((res) => res.json())
- .then((data) => {
- if (data.data) {
- return Object.values(data.data)[0];
- } else throw new Error(JSON.stringify(data.errors));
- });
- }
- export const backendURL = "http://chat.ed.asmer.org.ua";
- export const gql = getGQL(backendURL + "/graphql");
|