-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
66 lines (63 loc) · 2.03 KB
/
Copy pathapi.ts
File metadata and controls
66 lines (63 loc) · 2.03 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import axios from "axios";
const axiosInstance = axios.create({
withCredentials: true,
baseURL: "https://social-network.samuraijs.com/api/1.0/",
headers: { "API-KEY": "bf20d415-39bf-466e-8f6a-edbac4dc9ddc" },
});
const samuraiJsAPI = {
auth: {
authMe: () =>
axiosInstance.get("auth/me").then((response) => response.data),
login: (email, password, rememberMe = false, captcha) =>
axiosInstance
.post("auth/login", { email, password, rememberMe, captcha })
.then((response) => response.data),
logout: () =>
axiosInstance.delete("auth/login").then((response) => response.data),
},
profile: {
userId: (id) =>
axiosInstance.get(`profile/${id}`).then((response) => response.data),
status: (status) =>
axiosInstance.put("profile/status/", { status: status }),
getStatus: (id) =>
axiosInstance
.get(`profile/status/${id}`)
.then((response) => response.data),
photo: (file) =>
axiosInstance
.put("profile/photo/", file, {
headers: { "Content-Type": "multipart/form-data" },
})
.then((response) => response.data),
profile: (profileData) =>
axiosInstance
.put("profile", profileData)
.then((response) => response.data),
},
users: {
users: (count = 10, page = 1, term = "", friend = null) =>
axiosInstance
.get(
`users/?page=${page}&count=${count}&term=${term}&friend=${friend}&friend=${friend}`
)
.then((response) => response.data),
},
follow: {
userId: {
isFollowed: (id) =>
axiosInstance.get(`follow/${id}`).then((response) => response.data),
follow: (id) =>
axiosInstance.post(`follow/${id}`).then((response) => response.data),
unfollow: (id) =>
axiosInstance.delete(`follow/${id}`).then((response) => response.data),
},
},
security: {
getCaptchaUrl: () =>
axiosInstance
.get("security/get-captcha-url")
.then((response) => response.data),
},
};
export default samuraiJsAPI;