Created
April 29, 2022 22:37
-
-
Save ChristianOConnor/7f8e310038d0f681f782c1d49ffba98c to your computer and use it in GitHub Desktop.
DynamicComponentWithNoSSR attempt 042922 components/
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
import React from 'react'; | |
import { Button } from 'react-bootstrap'; | |
import { GoogleAuth } from 'google-auth-library'; | |
const url = "https://us-central1-<projectId>.cloudfunctions.net/<functionName>"; | |
const keyFilename = "/path/to/key.json"; | |
class Middle extends React.Component { | |
async main() { | |
const auth = new GoogleAuth({keyFilename: keyFilename}) | |
//Create your client with an Identity token. | |
const client = await auth.getIdTokenClient(url); | |
const res = await client.request({url}); | |
console.log(res.data); | |
} | |
render() { | |
return ( | |
<div className="col-md-12 text-center"> | |
<Button variant='primary' onClick={this.main}> | |
Click me | |
</Button> | |
</div> | |
); | |
} | |
} | |
export default Middle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment