* @param {object} params - object containing the parameters for the api request * @returns {object} response from the api */ import axios from 'axios'; const baseUrl = process.env.REACT_APP_API_URL || "http://localhost:8080"; //create post export const createPost = (params) => { return new Promise((resolve, reject) => { axios.post(baseUrl + '/posts', params) .then(response => { resolve(response); }) .catch(error => { reject(error); }); }); }; //get all posts export const getAllPosts = (params) => { return new Promise((resolve, reject) => { axios.get(baseUrl + '/posts', params) .then(response => { resolve(response); }) .catch(error => { reject(error); }); }); }; //get one post export const getOnePost = (params) => { return new Promise((resolve, reject) => { axios.get(baseUrl + '/posts/' + params) .then(response => { resolve(response); }) .catch(error => { reject(error); }); }); }; //update post export const updatePost = (params) => { return new Promise((resolve, reject) => { axios.put(baseUrl + '/posts/' + params) .then(response => { resolve(response); }) .catch(error => { reject(error); }); }); }; //delete post export const deletePost = (params) => { return new Promise((resolve, reject) => { axios.delete(baseUrl + '/posts/' + params) .then(response => { resolve(response); }) .catch(error => { reject(error); }); }); };