Skip to content

Instantly share code, notes, and snippets.

@revskill10
Forked from stubailo/fetch-graphql.js
Created February 6, 2019 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revskill10/33ddfac949cbfbce71fcf7453d4b4696 to your computer and use it in GitHub Desktop.
Save revskill10/33ddfac949cbfbce71fcf7453d4b4696 to your computer and use it in GitHub Desktop.
Call a GraphQL API with fetch
require('isomorphic-fetch');
fetch('https://1jzxrj179.lp.gql.zone/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: '{ posts { title } }' }),
})
.then(res => res.json())
.then(res => console.log(res.data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment