34 lines
975 B
JavaScript
34 lines
975 B
JavaScript
import axios from "axios";
|
|
|
|
const BASE_URL = import.meta.env.VITE_REACT_APP_SECRET;
|
|
|
|
// const API = axios.create({baseURL:"http://localhost:3001"});
|
|
// const API = axios.create({ baseURL: `${BASE_URL}` });
|
|
const API = axios.create({ baseURL: BASE_URL });
|
|
|
|
|
|
API.interceptors.request.use((req) => {
|
|
if (localStorage.getItem("profile")) {
|
|
req.headers.Authorization = `Bearer ${
|
|
JSON.parse(localStorage.getItem("profile")).token
|
|
}`;
|
|
}
|
|
return req;
|
|
});
|
|
|
|
export const signUp = (formData) => API.post("/users/signup", formData);
|
|
export const signIn = (formData) => API.post("/users/signin", formData);
|
|
export const verifyEmail = (id, token, data) => API.get(`/users/${id}/verify/${token}`, data);
|
|
export const submitProperty = (propertyData) => API.post("/properties", propertyData);
|
|
export const fetchUserProperties = (userId) => API.get(`/properties/user/${userId}`, userId);
|
|
export const fetchPropertyById = (id) => API.get(`/properties/${id}`, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|