Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created April 29, 2022 22:37
Show Gist options
  • Save ChristianOConnor/7f8e310038d0f681f782c1d49ffba98c to your computer and use it in GitHub Desktop.
Save ChristianOConnor/7f8e310038d0f681f782c1d49ffba98c to your computer and use it in GitHub Desktop.
DynamicComponentWithNoSSR attempt 042922 components/
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