Skip to content

Instantly share code, notes, and snippets.

@fforw
Created February 5, 2023 19:40
Show Gist options
  • Select an option

  • Save fforw/2e8a12baf9ef430d5bb410f83c624880 to your computer and use it in GitHub Desktop.

Select an option

Save fforw/2e8a12baf9ef430d5bb410f83c624880 to your computer and use it in GitHub Desktop.
// query is a GraphQL query definition and variables an object whose keys are variable values for that definition
fetch(
"/graphql",
{
method: "POST",
credentials: "same-origin",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
query,
variables
})
}
)
.then(response => response.json())
.then(({ data, errors}) => ... )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment