mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
New Home page, New UI, Proxy api requests through next.js api routes
This commit is contained in:
parent
49b9ac069f
commit
a30ddcfc6a
20 changed files with 5385 additions and 0 deletions
31
app/api/utils.js
Normal file
31
app/api/utils.js
Normal 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);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue