Skip to content

Instantly share code, notes, and snippets.

@heitorlessa
Created August 9, 2019 12:58
Show Gist options
  • Save heitorlessa/b287228ae481cead48e44ffeafabc5f3 to your computer and use it in GitHub Desktop.
Save heitorlessa/b287228ae481cead48e44ffeafabc5f3 to your computer and use it in GitHub Desktop.
axios_appsync_snippet
const user = {
credentials: rootState.profile.user.signInUserSession.accessToken.jwtToken,
id: rootState.profile.user.attributes.sub
}
const fetchLoyaltyQuery = `query getLoyalty_status($cust_id: ID!) {
getLoyalty_status(cust_id: $cust_id) {
cust_id
points
tier
remaining_pointss
}
}`
const result = await axios({
url: 'https://q3irg2wqnzewzb56wrzzckyodi.appsync-api.eu-west-1.amazonaws.com/graphql',
method: 'post',
data: {
query: fetchLoyaltyQuery,
variables: {
cust_id: user.id
}
},
headers: {
Authorization: user.credentials,
'Content-Type': 'application/json'
}
})
const {
data: { getLoyalty_status: loyaltyData }
} = result.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment