gql.js 421 B

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