forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1import axios from "axios";
2import { API_URL } from "../consts";
3
4export const play = async () => {
5 const response = await axios.put(
6 `${API_URL}/spotify/play`,
7 {},
8 {
9 headers: {
10 "Content-Type": "application/json",
11 Authorization: `Bearer ${localStorage.getItem("token")}`,
12 },
13 },
14 );
15 return response.data;
16};
17
18export const pause = async () => {
19 const response = await axios.put(
20 `${API_URL}/spotify/pause`,
21 {},
22 {
23 headers: {
24 "Content-Type": "application/json",
25 Authorization: `Bearer ${localStorage.getItem("token")}`,
26 },
27 },
28 );
29 return response.data;
30};
31
32export const next = async () => {
33 const response = await axios.post(
34 `${API_URL}/spotify/next`,
35 {},
36 {
37 headers: {
38 "Content-Type": "application/json",
39 Authorization: `Bearer ${localStorage.getItem("token")}`,
40 },
41 },
42 );
43 return response.data;
44};
45
46export const previous = async () => {
47 const response = await axios.post(
48 `${API_URL}/spotify/previous`,
49 {},
50 {
51 headers: {
52 "Content-Type": "application/json",
53 Authorization: `Bearer ${localStorage.getItem("token")}`,
54 },
55 },
56 );
57 return response.data;
58};
59
60export const seek = async (position_ms: number) => {
61 const response = await axios.put(
62 `${API_URL}/spotify/seek`,
63 {},
64 {
65 headers: {
66 "Content-Type": "application/json",
67 Authorization: `Bearer ${localStorage.getItem("token")}`,
68 },
69 params: {
70 position_ms,
71 },
72 },
73 );
74 return response.data;
75};