gql.js 444 B

12345678910111213141516
  1. const getGQL =
  2. (url) =>
  3. (query, variables = {}) =>
  4. fetch(url, {
  5. method: "POST",
  6. headers: {
  7. //Accept: "application/json",
  8. "Content-Type": "application/json",
  9. ...(localStorage.authToken
  10. ? { Authorization: "Bearer " + localStorage.authToken }
  11. : {}),
  12. },
  13. body: JSON.stringify({ query, variables }),
  14. }).then((res) => res.json());
  15. export const gql = getGQL("/graphql");