Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Last active April 14, 2021 09:00
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 buddies2705/be44d25c50bb76f04a148d37593902f8 to your computer and use it in GitHub Desktop.
Save buddies2705/be44d25c50bb76f04a148d37593902f8 to your computer and use it in GitHub Desktop.
Using GraphQL by Javascript
const query = `
query{
bitcoin{
blocks{
count
}
}
}
`;
const url = "https://graphql.bitquery.io/";
const opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR API KEY"
},
body: JSON.stringify({
query
})
};
fetch(url, opts)
.then(res => res.json())
.then(console.log)
.catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment