Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-web
Commits
26573c86
Commit
26573c86
authored
Jul 29, 2017
by
Mattias J Duffy
Browse files
made first api call
parent
bca37835
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
26573c86
...
...
@@ -3,6 +3,7 @@
# dependencies
/node_modules
/proxyServer/node_modules
# testing
/coverage
...
...
src/actions/action-types.js
View file @
26573c86
export
const
TOGGLE_DRAWER
=
'
TOGGLE_DRAWER
'
;
export
const
CALL_API
=
'
CALL_API
'
src/actions/api.js
0 → 100644
View file @
26573c86
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
])
})
}
}
src/components/Drawer.js
View file @
26573c86
...
...
@@ -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
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment