diff --git a/packages/server/packages/play-node-go/src/App.js b/packages/server/packages/play-node-go/src/App.js index 241ed97..83c03f9 100644 --- a/packages/server/packages/play-node-go/src/App.js +++ b/packages/server/packages/play-node-go/src/App.js @@ -1,14 +1,21 @@ -import React from 'react'; +import React, {useState} from 'react'; import './App.scss'; import config from './config'; +import socketIOClient from 'socket.io-client'; +export const socket = socketIOClient(config.apiAddress); + function App() { - let fetchData = {}; - fetch(config.apiAddress).then(res => {console.log(res);fetchData = res.body}).then(() => console.log(fetchData)) + const [fetchData, setFetchData] = useState(); + const [socketData, setSocketData] = useState(); + fetch(config.apiAddress).then(res => res.text()).then(data => setFetchData(data)); + socket.emit('connect'); + socket.on('connected', data => setSocketData(data.message)); return (
{fetchData}
: <>>} + {socketData ?{socketData}
: <>>}