Last active
December 30, 2020 08:20
-
-
Save dabit3/f1895091d9536235704dcf9d1c9a7d7e to your computer and use it in GitHub Desktop.
Enabling SSR support in Amplify
This file contains hidden or 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
// Enable SSR support in Amplify app | |
Amplify.configure({ ...config, ssr: true }) | |
// Library usage in SSR or API routes | |
import { withSSRContext } from 'aws-amplify' | |
const { Auth, API } = withSSRContext({ req }) | |
// Get user session | |
const user = await Auth.currentAuthenticatedUser() | |
// Make authenticated GraphQL API call | |
const data = await API.graphql({ query: someQuery }) | |
// Make authenticated REST API call | |
const data = await API.get('myapi', '/posts') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slight typo on line 12.
graphqlkgraphql