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

e

parent 0560f339
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;
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 getJoinRoom(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)
getJoinRoom(id)
}, [id])
return (
......
......@@ -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
};
......@@ -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;
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