Просмотр исходного кода

Putting the API key in the UI now that it's safely restricted

Kirk Trombley 5 лет назад
Родитель
Сommit
cf286feb9a

+ 1 - 23
client/src/components/with-google-key.component.jsx

@@ -1,27 +1,5 @@
 import React from "react";
-import { getGoogleApiKey } from "../services/ggsh.service";
-import Loading from "./loading.component";
 
-const withGoogleApiKey = ComposedComponent =>
-  class extends React.Component {
-    constructor(props) {
-      super(props);
-      this.state = { googleApiKey: null }
-    }
-
-    async componentDidMount() {
-      const googleApiKey = await getGoogleApiKey();
-      this.setState({ googleApiKey });
-    }
-
-    render() {
-      const { googleApiKey } = this.state;
-      if (!googleApiKey) {
-        return <Loading/>
-      }
-
-      return <ComposedComponent {...this.props} googleApiKey={googleApiKey} />
-    }
-  }
+const withGoogleApiKey = ComposedComponent => props => <ComposedComponent {...props} googleApiKey="AIzaSyCDtEWf192OYuMvd2cp8a04DYQo-RU_sXs" />
 
 export default withGoogleApiKey;

+ 0 - 10
client/src/services/ggsh.service.js

@@ -12,16 +12,6 @@ export const getStatus = async () => {
     }
 }
 
-// TODO save this after the first call since it will never change
-export const getGoogleApiKey = async () => {
-    const res = await fetch(`${API_BASE}/googleApiKey`);
-    if (!res.ok) {
-        throw Error(res.statusText);
-    }
-    const { googleApiKey } = await res.json();
-    return googleApiKey;
-}
-
 export const createGame = async (name, timer) => {
     const res = await fetch(`${API_BASE}/game`, {
         method: "PUT",