-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.ts
33 lines (25 loc) · 906 Bytes
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import axios from "axios";
const pvApi = axios.create({
baseURL: "https://purrviews-api.onrender.com/api",
});
export const getPosts = () => {
return pvApi.get("/posts").then((res) => res.data.posts);
};
export const getUsers = () => {
return pvApi.get("/users").then((res) => res.data.users);
};
export const getUsersByUsername = (username) => {
return pvApi.get(`/users/${username}`).then((res) => res.data.users);
};
export const getLostCats = () => {
return pvApi.get("/cats/missing").then((res) => res.data.users);
};
export const postUser = (user) => {
return pvApi.post("/users", user).then((res) => res.data.user);
};
export const postPost = (newPost) => {
return pvApi.post("/posts", newPost).then((res) => res.data.post);
};
export const postCat = (username, cat: any) => {
return pvApi.post(`/users/${username}/cats`, cat).then((res) => res.data.cat);
};