stub basic connection

This commit is contained in:
Sorrel Bri 2020-01-07 13:03:59 -08:00
parent 9f8d504e95
commit b025adc6a7
4 changed files with 25 additions and 3 deletions

View file

@ -13,11 +13,14 @@
"socket.io-client": "^2.3.0" "socket.io-client": "^2.3.0"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "REACT_APP_ENVIRONMENT='development' react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"flow": "flow" "flow": "flow",
"predeploy": "REACT_APP_ENVIRONMENT=production npm run build"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"

View file

@ -12,7 +12,7 @@ var http = require('http');
* Get port from environment and store in Express. * Get port from environment and store in Express.
*/ */
var port = normalizePort(process.env.PORT || '3000'); var port = normalizePort(process.env.PORT || '8000');
app.set('port', port); app.set('port', port);
/** /**

View file

@ -1,10 +1,14 @@
import React from 'react'; import React from 'react';
import './App.scss'; import './App.scss';
import config from './config';
function App() { function App() {
let fetchData = {};
fetch(config.apiAddress).then(res => {console.log(res);fetchData = res.body}).then(() => console.log(fetchData))
return ( return (
<div className="App"> <div className="App">
<h1>React Boilerplate</h1> <h1>React Boilerplate</h1>
{fetchData ? <p></p> : <></>}
</div> </div>
); );
} }

15
src/config.js Normal file
View file

@ -0,0 +1,15 @@
const production = {
apiAddress: null
}
const development = {
apiAddress: 'http://localhost:8000'
}
const config = process.env.REACT_APP_ENVIRONMENT === 'production'
? production
: development
export default {
...config
}