Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
bora-it
Commits
6d97fb5a
Commit
6d97fb5a
authored
Jul 27, 2021
by
우지원
Browse files
e
parent
0560f339
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/apis/room.api.js
View file @
6d97fb5a
import
axios
from
"
axios
"
;
const
getRoom
=
async
(
payload
)
=>
{
const
{
data
}
=
await
axios
.
get
(
"
/api/room/getRoom
"
,
payload
);
return
data
;
};
const
create
=
async
(
payload
)
=>
{
const
{
data
}
=
await
axios
.
post
(
"
/api/room/create
"
,
payload
);
return
data
;
...
...
@@ -10,6 +15,6 @@ const join = async (payload) => {
return
data
;
};
const
roomApi
=
{
create
,
join
};
const
roomApi
=
{
getRoom
,
create
,
join
};
export
default
roomApi
;
client/src/components/Home/RoomSingle.js
View file @
6d97fb5a
import
{
useEffect
,
useState
}
from
'
react
'
;
import
{
Link
}
from
'
react-router-dom
'
import
roomApi
from
'
../../apis/room.api
'
;
import
userApi
from
'
../../apis/user.api
'
;
const
RoomSingle
=
()
=>
{
const
[
room
,
setRoom
]
=
useState
(
''
)
const
[
roomNum
,
setRoomNum
]
=
useState
([])
const
[
room
,
setRoom
]
=
useState
([])
const
id
=
localStorage
.
getItem
(
'
user
'
);
const
channelId
=
1
async
function
getRoom
(
id
)
{
async
function
get
Join
Room
(
id
)
{
try
{
const
Room
=
await
userApi
.
getUser
(
id
)
setRoom
(
Room
.
data
.
roomNumber
)
const
User
=
await
userApi
.
getUser
(
id
)
setRoomNum
(
User
.
data
.
roomNumber
)
const
Room
=
await
roomApi
.
getRoom
(
roomNum
)
}
catch
(
error
)
{
// catchErrors(error, setError)
}
}
useEffect
(()
=>
{
getRoom
(
id
)
get
Join
Room
(
id
)
},
[
id
])
return
(
...
...
controllers/room.controller.js
View file @
6d97fb5a
...
...
@@ -78,6 +78,10 @@ const createRoom = async (req, res) => {
}
}
const
getRoom
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
req.body:
'
,
req
.
body
)
}
export
default
{
joinRoom
,
createRoom
joinRoom
,
createRoom
,
getRoom
};
routes/room.route.js
View file @
6d97fb5a
...
...
@@ -2,9 +2,8 @@ import express from "express";
import
roomCrtl
from
"
../controllers/room.controller.js
"
;
const
router
=
express
.
Router
();
router
.
route
(
"
/getRoom
"
).
get
(
roomCrtl
.
getRoom
);
router
.
route
(
"
/create
"
).
post
(
roomCrtl
.
createRoom
);
router
.
route
(
"
/join
"
).
put
(
roomCrtl
.
joinRoom
);
export
default
router
;
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