I am having trouble finding a way to translate the below methods written with Axios to fetch.
import axios from 'axios';
const url = 'http://localhost:5000/api/posts/';
The URL is running from port 5000 from my server using 'npm run dev'
class PostService {
//Get Posts
static getPosts() {
    return new Promise(async (resolve, reject) => {
        try {
            const res = await axios.get(url);
            const data = res.data;
            resolve(
                data.map(post => ({
                    ...post,
                    createdAt: new Date(post.createdAt)
                }))
            );
        } catch (err) {
            reject(err);
        }
    })
}
The above is using a promise and axios to map the data
//Create Posts
static insertPost(text, topic, price, location, provider, review) {
    return axios.post(url, {
        text,
        topic,
        price,
        location,
        provider,
        review
    });
}
The above is returning the data using axios
//Delete Posts
static deletePost(id) {
    return axios.delete(`${url}${id}`);
}
}
The above is finding ID of DB entry and using axios to delete it.
export default PostService;
 
     
     
    