Created
August 9, 2019 12:58
-
-
Save heitorlessa/b287228ae481cead48e44ffeafabc5f3 to your computer and use it in GitHub Desktop.
axios_appsync_snippet
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 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