Commit 1090e69e authored by Kim, Chaerin's avatar Kim, Chaerin
Browse files

에러해결 및 api 파일 복사

parent 5bc56dd0
const endpoints = {
API_BASE_URL: "http://localhost:8080/api",
ROOM_API: "room",
PROFILE_API: "profile",
};
export default endpoints;
import axios from "axios";
const login = async (payload) => {
const { data } = await axios.post("/api/login", payload);
return data;
};
const signup = async (payload) => {
const { data } = await axios.post("/api/signup", payload);
return data;
};
const profileApi = { login, signup };
export default profileApi;
import axios from "axios";
const login = async (payload) => {
const { data } = await axios.post("/api/login", payload);
return data;
};
const signup = async (payload) => {
const { data } = await axios.post("/api/signup", payload);
return data;
};
const roomApi = { login, signup };
export default roomApi;
import axios from "axios"; import axios from "axios";
import endpoints from "./endpoints";
const login = async (payload) => { const login = async (payload) => {
const { data } = await axios.post(`${endpoints.API_BASE_URL}/login`, payload); const { data } = await axios.post("/api/login", payload);
console.log(data);
return data; return data;
}; };
const signup = async (payload) => { const signup = async (payload) => {
const { data } = await axios.post( const { data } = await axios.post("/api/signup", payload);
`${endpoints.API_BASE_URL}/signup`,
payload
);
return data; return data;
}; };
......
...@@ -7,7 +7,7 @@ const Header = () => { ...@@ -7,7 +7,7 @@ const Header = () => {
className="flex-column align-items-center justify-content-center p-2" className="flex-column align-items-center justify-content-center p-2"
> >
<div className="d-flex justify-content-center"> <div className="d-flex justify-content-center">
<Link to="/user"> <Link to="/">
<img src="/BORA.png" style={{ width: '160px' }} /> <img src="/BORA.png" style={{ width: '160px' }} />
</Link> </Link>
</div> </div>
......
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Redirect } from "react-router-dom"; import { Redirect } from "react-router-dom";
import login from "../apis/user.api"; import userApi from "../apis/user.api";
const INIT_USER = { const INIT_USER = {
email: "", email: "",
password: "", password: "",
...@@ -28,7 +28,7 @@ const Login = () => { ...@@ -28,7 +28,7 @@ const Login = () => {
try { try {
// setLoading(true); // setLoading(true);
// setError(""); // setError("");
const data = await login(user); const data = await userApi.login(user);
console.log(data); console.log(data);
setSuccess(true); setSuccess(true);
} catch (error) { } catch (error) {
......
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