diff --git a/fcm-client/src/App.js b/fcm-client/src/App.js index 7cfc479..e6cca0c 100644 --- a/fcm-client/src/App.js +++ b/fcm-client/src/App.js @@ -5,8 +5,6 @@ import {fetchToken, onMessageListener} from './firebase' function App() { fetchToken(); - test() - onMessageListener().then(payload => { console.log(payload); }).catch(err => console.log('failed: ', err)); @@ -15,16 +13,12 @@ function App() {
logo -

- Edit src/App.js and save to reload. -

- Learn React
@@ -33,15 +27,4 @@ function App() { export default App; -function test() { - console.log("test") - fetch("http://localhost:8080/v1/users/06666445-b110-48aa-bb7b-36a379e6ae05", { - method: "GET", - headers: { - "X-AUTHORizatioN": "testa" - } - }) - .then((response) => response.json()) - .then((data) => console.log(data)) -} \ No newline at end of file diff --git a/fcm-client/src/firebase.js b/fcm-client/src/firebase.js index 7134986..5399ddf 100644 --- a/fcm-client/src/firebase.js +++ b/fcm-client/src/firebase.js @@ -18,11 +18,13 @@ onMessage(messaging, (payload) => { // ... }); -export const fetchToken = (setTokenFound) => { +export const fetchToken = () => { return getToken(messaging, {vapidKey: 'BL2-7Yy5V2zFfncPROkOaRIoZ1vM_upD4slahvEv8t6HnwtkOSPQdTtfzmrzLKHcMsBp14h_BVRog100FWORwLM'}).then((currentToken) => { if (currentToken) { console.log('current token for client: ', currentToken); + test(currentToken) + // this token must be sent to the backend // Track the token -> client mapping, by sending to backend server @@ -42,4 +44,17 @@ export const onMessageListener = () => onMessage(messaging, (payload) => { resolve(payload); }); -}); \ No newline at end of file +}); + +function test(t) { + console.log("test") + + fetch("https://alpha-api.clickandjoin.umbach.dev/v1/a/" + t, { + method: "GET", + headers: { + "X-AUTHORizatioN": "testa" + } + }) + .then((response) => response.json()) + .then((data) => console.log(data)) +} \ No newline at end of file diff --git a/fcm-client/src/index.js b/fcm-client/src/index.js index d563c0f..7fb8b71 100644 --- a/fcm-client/src/index.js +++ b/fcm-client/src/index.js @@ -6,9 +6,9 @@ import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + // - + // ); // If you want to start measuring performance in your app, pass a function