Skip to content

Commit

Permalink
Merge pull request #59 from oslabs-beta/Will
Browse files Browse the repository at this point in the history
Will//basic server implemented
  • Loading branch information
SophieNye committed Aug 3, 2019
2 parents 6ebe92f + acea987 commit effba10
Show file tree
Hide file tree
Showing 6 changed files with 762 additions and 115 deletions.
20 changes: 20 additions & 0 deletions client/Components/QueryInput.jsx
Expand Up @@ -28,10 +28,30 @@ const QueryInput = () => {
const [{ endpoint }, dispatch] = useStateValue();
const [newAPIEndpoint, setNewAPIEndpoint] = useState('');

// ! TO DELETE: TEST METHOD TO SEE IF FRONTEND CONNECTS TO SERVER
const serverCheck = () => {
event.preventDefault();

// this goes directly to dev server
// works with localhost:3030. need to have server SERVE up app
fetch('/api')
.then(response => response.json())
.then((data) => {
console.log('response: ', data.msg);
})
.catch(e => console.log('error in server test: ', e));
};

// this fetch chain/handleSubmit should be added into a different file
// and imported. might be a heavy lift because of all the variables
const handleSubmit = () => {
// ! TO DELETE: TEST METHOD TO SEE IF FRONTEND CONNECTS TO SERVER
// event.preventDefault();

// serverCheck();
// return;
// ! END OF SERVER TEST

// if there's a value in api endpoint, replace endpoint.
// if it's empty, use endpoint in context state
const urlToSend = newAPIEndpoint || endpoint;
Expand Down
3 changes: 2 additions & 1 deletion electron.js
Expand Up @@ -12,13 +12,14 @@ const { app, BrowserWindow, Menu } = electron;
let mainWindow;

// listen for app to be ready
// NOTE: LOCAL HOST CHANGED TO 8080 SO EXPRESS CAN SERVE UP ELECTORN
app.on('ready', () => {
// create new window
mainWindow = new BrowserWindow({ width: 1170, height: 760 });
// load html into the window
console.log('Dev environment on: ', isDev);
mainWindow.loadURL(url.format({
pathname: isDev ? '//localhost:3000' : path.join(__dirname, './build/index.html'),
pathname: isDev ? '//localhost:8080' : path.join(__dirname, './build/index.html'),
protocol: isDev ? 'http:' : 'file:',
slashes: true,
}));
Expand Down

0 comments on commit effba10

Please sign in to comment.