Skip to content

Instantly share code, notes, and snippets.

@philiptzou
Last active September 30, 2016 02:14
Show Gist options
  • Save philiptzou/93019da458c429b3a13513ba9b79407c to your computer and use it in GitHub Desktop.
Save philiptzou/93019da458c429b3a13513ba9b79407c to your computer and use it in GitHub Desktop.
/**
* A simple script to initial a request to Sierra GraphQL service
* and then output current HIVDB version in an alert window.
*/
window.fetch('https://hivdb.stanford.edu/graphql', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: 'query { viewer { currentVersion { text } } }',
variables: {}
})
})
.then(response => response.json())
.then(({data: {viewer: {currentVersion}}}) => (
alert(`Current HIVDB version: ${currentVersion.text}`)
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment