A decentralized music tracking and discovery platform built on AT Protocol 馃幍
at feat/feed-generator 86 lines 2.1 kB view raw
1import axios from "axios"; 2import { API_URL } from "../consts"; 3 4export const shout = async (uri: string, message: string) => { 5 const response = await axios.post( 6 `${API_URL}/users/${uri.replace("at://", "")}/shouts`, 7 { message }, 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 getShouts = async (uri: string) => { 19 const response = await axios.get( 20 `${API_URL}/users/${uri.replace("at://", "")}/shouts`, 21 { 22 headers: { 23 Authorization: `Bearer ${localStorage.getItem("token")}`, 24 }, 25 }, 26 ); 27 return response.data; 28}; 29 30export const reply = async (uri: string, message: string) => { 31 const response = await axios.post( 32 `${API_URL}/users/${uri.replace("at://", "")}/replies`, 33 { message }, 34 { 35 headers: { 36 "Content-Type": "application/json", 37 Authorization: `Bearer ${localStorage.getItem("token")}`, 38 }, 39 }, 40 ); 41 return response.data; 42}; 43 44export const getReplies = async (uri: string) => { 45 const response = await axios.get( 46 `${API_URL}/users/${uri.replace("at://", "")}/replies`, 47 ); 48 return response.data; 49}; 50 51export const reportShout = async (uri: string) => { 52 const response = await axios.post( 53 `${API_URL}/users/${uri.replace("at://", "")}/report`, 54 {}, 55 { 56 headers: { 57 Authorization: `Bearer ${localStorage.getItem("token")}`, 58 }, 59 }, 60 ); 61 return response.data; 62}; 63 64export const deleteShout = async (uri: string) => { 65 const response = await axios.delete( 66 `${API_URL}/users/${uri.replace("at://", "")}`, 67 { 68 headers: { 69 Authorization: `Bearer ${localStorage.getItem("token")}`, 70 }, 71 }, 72 ); 73 return response.data; 74}; 75 76export const cancelReport = async (uri: string) => { 77 const response = await axios.delete( 78 `${API_URL}/users/${uri.replace("at://", "")}/report`, 79 { 80 headers: { 81 Authorization: `Bearer ${localStorage.getItem("token")}`, 82 }, 83 }, 84 ); 85 return response.data; 86};