New Home page, New UI, Proxy api requests through next.js api routes

This commit is contained in:
Kentai Radiquum 2024-07-11 07:33:56 +05:00
parent 49b9ac069f
commit a30ddcfc6a
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
20 changed files with 5385 additions and 0 deletions

31
app/api/utils.js Normal file
View file

@ -0,0 +1,31 @@
import { USER_AGENT } from "./config";
export const HEADERS = {
"User-Agent": USER_AGENT,
"Content-Type": "application/json; charset=UTF-8",
};
export const fetchDataViaGet = async (url) => {
try {
const response = await fetch(url, {
headers: HEADERS,
});
const data = await response.json();
return data;
} catch (error) {
console.log(error);
}
};
export const fetchDataViaPost = async (url, body) => {
try {
const response = await fetch(url, {
method: "POST",
headers: HEADERS,
body: JSON.stringify(body),
});
const data = await response.json();
return data;
} catch (error) {
console.log(error);
}
};