gql.js 427 B

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