import axios from "axios"; import baseUrl from "./baseUrl"; import { PostType } from "../types"; export const createImgAndPost = async (formdata: FormData) => { const { data } = await axios.post(`${baseUrl}/posts/`, formdata); return data; }; export const getData = async () => { const { data } = await axios.get(`${baseUrl}/posts/`); return data; }; export const getImgData = async (name: string) => { const { data } = await axios.get(`/images/${name}`); return data; }; export const addCounts = async (_id: string, counts: number) => { const { data } = await axios.post(`${baseUrl}/posts/${_id}`, { counts: counts + 1, }); return data; }; export const getPostByPostId = async (_id: string) => { const { data } = await axios.get(`${baseUrl}/posts/${_id}`); return data; }; export const deletePost = async (_id: string) => { const { data } = await axios.delete(`${baseUrl}/posts/${_id}`); return data; }; export const updating = async (post: PostType) => { const { data } = await axios.put(`${baseUrl}/posts/${post._id}`, post); return data; };