Last active
April 14, 2021 09:00
-
-
Save buddies2705/be44d25c50bb76f04a148d37593902f8 to your computer and use it in GitHub Desktop.
Using GraphQL by Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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