Commit 6d97fb5a authored by 우지원's avatar 우지원
Browse files

e

parent 0560f339
import axios from "axios"; import axios from "axios";
const getRoom = async (payload) => {
const { data } = await axios.get("/api/room/getRoom", payload);
return data;
};
const create = async (payload) => { const create = async (payload) => {
const { data } = await axios.post("/api/room/create", payload); const { data } = await axios.post("/api/room/create", payload);
return data; return data;
...@@ -10,6 +15,6 @@ const join = async (payload) => { ...@@ -10,6 +15,6 @@ const join = async (payload) => {
return data; return data;
}; };
const roomApi = { create, join }; const roomApi = { getRoom, create, join };
export default roomApi; export default roomApi;
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import roomApi from '../../apis/room.api';
import userApi from '../../apis/user.api'; import userApi from '../../apis/user.api';
const RoomSingle = () => { const RoomSingle = () => {
const [room, setRoom] = useState('') const [roomNum, setRoomNum] = useState([])
const [room, setRoom] = useState([])
const id = localStorage.getItem('user'); const id = localStorage.getItem('user');
const channelId = 1 const channelId = 1
async function getRoom(id) { async function getJoinRoom(id) {
try { try {
const Room = await userApi.getUser(id) const User = await userApi.getUser(id)
setRoom(Room.data.roomNumber) setRoomNum(User.data.roomNumber)
const Room = await roomApi.getRoom(roomNum)
} catch (error) { } catch (error) {
// catchErrors(error, setError) // catchErrors(error, setError)
} }
} }
useEffect(() => { useEffect(() => {
getRoom(id) getJoinRoom(id)
}, [id]) }, [id])
return ( return (
......
...@@ -78,6 +78,10 @@ const createRoom = async (req, res) => { ...@@ -78,6 +78,10 @@ const createRoom = async (req, res) => {
} }
} }
const getRoom = async(req,res) => {
console.log('req.body:',req.body)
}
export default { export default {
joinRoom, createRoom joinRoom, createRoom, getRoom
}; };
...@@ -2,9 +2,8 @@ import express from "express"; ...@@ -2,9 +2,8 @@ import express from "express";
import roomCrtl from "../controllers/room.controller.js"; import roomCrtl from "../controllers/room.controller.js";
const router = express.Router(); const router = express.Router();
router.route("/getRoom").get(roomCrtl.getRoom);
router.route("/create").post(roomCrtl.createRoom); router.route("/create").post(roomCrtl.createRoom);
router.route("/join").put(roomCrtl.joinRoom); router.route("/join").put(roomCrtl.joinRoom);
export default router; export default router;
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