gql.js 341 B

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