refactored/cleaned up API + added support for renaming tags
This commit is contained in:
@@ -22,9 +22,7 @@ const addMemberToCollection = async (
|
||||
memberUsername.trim().toLowerCase() !== ownerUsername.toLowerCase()
|
||||
) {
|
||||
// Lookup, get data/err, list ...
|
||||
const user = await getPublicUserData({
|
||||
username: memberUsername.trim().toLowerCase(),
|
||||
});
|
||||
const user = await getPublicUserData(memberUsername.trim().toLowerCase());
|
||||
|
||||
if (user.username) {
|
||||
setMember({
|
||||
|
||||
@@ -17,7 +17,7 @@ const getPublicCollectionData = async (
|
||||
const encodedData = encodeURIComponent(JSON.stringify(requestBody));
|
||||
|
||||
const res = await fetch(
|
||||
"/api/public/collections?body=" + encodeURIComponent(encodedData)
|
||||
"/api/v1/public/collections?body=" + encodeURIComponent(encodedData)
|
||||
);
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
export default async function getPublicUserData({
|
||||
username,
|
||||
id,
|
||||
}: {
|
||||
username?: string;
|
||||
id?: number;
|
||||
}) {
|
||||
const response = await fetch(
|
||||
`/api/users?id=${id}&${
|
||||
username ? `username=${username?.toLowerCase()}` : undefined
|
||||
}`
|
||||
);
|
||||
export default async function getPublicUserData(id: number | string) {
|
||||
const response = await fetch(`/api/v1/users/${id}`);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user