dont ever buy api from the github bro

This commit is contained in:
amy 2024-09-29 19:53:36 +03:30
parent de77c0d6d8
commit fc400b4eab
3 changed files with 50 additions and 18 deletions

View file

@ -21,7 +21,7 @@ export default function Reviews() {
.then(response => response.json()) .then(response => response.json())
.then((data: Review[]) => { .then((data: Review[]) => {
const promises = data.map(review => ( const promises = data.map(review => (
fetch(`https://discordlookup.mesalytic.moe/v1/user/${review.discordID}`) fetch(`https://dc-lookup.mono.exhq.dev/v1/user/${review.discordID}`)
.then(response => response.json()) .then(response => response.json())
.then(user => ({ .then(user => ({
...review, ...review,
@ -66,16 +66,33 @@ export default function Reviews() {
} }
function SingleReview(props: NeoReview) { export const theImager = async (id: string): Promise<string> => (await fetch(`https://dc-lookup.mono.exhq.dev/v1/user/${id}`)
return <div class="singlereview"> .then(res => res.json()).then(data => data.avatar.link).catch(() => "https://http.cat/status/100"));
<img src={`https://dp.nea.moe/avatar/${props.discordID}.png`} />
<div class="reviewinfo">
<div class="reviewname"> {props.global_name === null ? props.username : props.global_name} </div>
<div class="reviewtext"> {props.reviewText}</div>
</div>
</div>
}
function SingleReview(props: NeoReview) {
const [imageSrc, setImageSrc] = createSignal("");
onMount(async () => {
const url = await theImager(props.discordID);
setImageSrc(url);
});
return (
<div class="singlereview">
<img
src={imageSrc()}
alt="User Avatar"
style={{ "max-width": "3em", "border-radius": "30%" }}
/>
<div class="reviewinfo">
<div class="reviewname">
{props.global_name === null ? props.username : props.global_name}
</div>
<div class="reviewtext">{props.reviewText}</div>
</div>
</div>
);
}
export async function sendReview(review: string, token: string): Promise<boolean> { export async function sendReview(review: string, token: string): Promise<boolean> {
try { try {
const response = await fetch(`https://api.review.exhq.dev/sendreview?review=${review}`, { const response = await fetch(`https://api.review.exhq.dev/sendreview?review=${review}`, {

View file

@ -1,3 +1,5 @@
import { createSignal, onMount } from "solid-js";
import { theImager } from "./api"
import "./comps.css" import "./comps.css"
// warning: this IS horrible code. its a joke. DO NOT try this at home because // warning: this IS horrible code. its a joke. DO NOT try this at home because
// your local senior programmer CAN and WILL hunt you down // your local senior programmer CAN and WILL hunt you down
@ -7,8 +9,24 @@ export function AdvancedBr({ count }: { count: number }) {
} }
export function SingularOomfie({ url, discordid }: { name: string, url: string, discordid: string }) { export function SingularOomfie({ url, discordid }: { name: string, url: string, discordid: string }) {
return <a href={url}><img class="tooltip" style={{ const [imageSrc, setImageSrc] = createSignal("");
onMount(async () => {
const url = await theImager(discordid);
setImageSrc(url);
});
return (
<a href={imageSrc()}>
<img
class="tooltip"
style={{
"max-width": "3em", "max-width": "3em",
"border-radius": "30%" "border-radius": "30%",
}} src={`https://dp.nea.moe/avatar/${discordid}.png`} alt="LMAO IMAGINE BEING BLIND" /> </a> }}
src={imageSrc()}
alt="LMAO IMAGINE BEING BLIND"
/>
</a>
);
} }

View file

@ -24,13 +24,10 @@ export async function getLatestItems(apiUrl: string) {
throw new Error(`API call failed with status ${response.status}`); throw new Error(`API call failed with status ${response.status}`);
} }
const data = await response.json(); const data = await response.json();
// Check if data is an array
if (!Array.isArray(data)) { if (!Array.isArray(data)) {
throw new Error('API response is not an array'); throw new Error('API response is not an array');
} }
// Slice the last 5 items
const lastFive = data.slice(-5); const lastFive = data.slice(-5);
// Print or use the lastFive array as needed
return lastFive; return lastFive;
} catch (error) { } catch (error) {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);