Commit 26573c86 authored by Mattias J Duffy's avatar Mattias J Duffy
Browse files

made first api call

parent bca37835
......@@ -3,6 +3,7 @@
# dependencies
/node_modules
/proxyServer/node_modules
# testing
/coverage
......
export const TOGGLE_DRAWER = 'TOGGLE_DRAWER';
export const CALL_API = 'CALL_API'
import { CALL_API } from './action-types'
export const apiTest = () =>{
return (dispatch) =>{
return fetch('/api/facilities',{'method':'get'}).then((res)=>{
return res.json()
},(error)=>{console.log(error)}).then(json =>{
console.log(json[0])
})
}
}
......@@ -2,9 +2,15 @@ import React from 'react';
import {withStyles, createStyleSheet} from 'material-ui/styles';
import { compose } from 'redux';
import Drawer from 'material-ui/Drawer';
import Button from 'material-ui/Button';
import {apiTest} from '../actions/api';
import {connect} from 'react-redux';
// import Paper from 'material-ui/Paper';
function customDrawer({ classes,isOpen,handleLeftClose }){
function customDrawer({ classes,isOpen,handleLeftClose, apiTest }){
const handleClick = () =>{
apiTest()
}
return (
<Drawer
open={isOpen}
......@@ -14,7 +20,7 @@ function customDrawer({ classes,isOpen,handleLeftClose }){
onClick={handleLeftClose}
>
<div className={classes.drawer}>
hi
<Button raised onClick={handleClick}>Call API</Button>
</div>
</Drawer>
)
......@@ -30,4 +36,4 @@ const styleSheet = createStyleSheet('Drawer', theme => ({
export default compose(withStyles(styleSheet))(customDrawer);
export default compose(connect(null,{ apiTest }),withStyles(styleSheet))(customDrawer);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment