mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 01:19:41 +05:00
feat: add release franchise to search results.
chore: update search API version
This commit is contained in:
parent
3a800a4933
commit
b1c18da065
4 changed files with 63 additions and 6 deletions
|
@ -12,7 +12,7 @@ export async function GET(request) {
|
|||
}
|
||||
const data = { query, searchBy: 0 };
|
||||
|
||||
const response = await fetchDataViaPost(url.toString(), data);
|
||||
const response = await fetchDataViaPost(url.toString(), data, true);
|
||||
if (!response) {
|
||||
return NextResponse.json({ message: "Bad request" }, { status: 400 });
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ export const HEADERS = {
|
|||
"Content-Type": "application/json; charset=UTF-8",
|
||||
};
|
||||
|
||||
export const fetchDataViaGet = async (url) => {
|
||||
export const fetchDataViaGet = async (url, API_V2) => {
|
||||
if (API_V2) {
|
||||
HEADERS["API-Version"] = "v2";
|
||||
}
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: HEADERS,
|
||||
|
@ -19,7 +22,10 @@ export const fetchDataViaGet = async (url) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const fetchDataViaPost = async (url, body) => {
|
||||
export const fetchDataViaPost = async (url, body, API_V2) => {
|
||||
if (API_V2) {
|
||||
HEADERS["API-Version"] = "v2";
|
||||
}
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
|
@ -66,3 +72,11 @@ export function getJWT() {
|
|||
export function removeJWT() {
|
||||
localStorage.removeItem("JWT");
|
||||
}
|
||||
|
||||
export function numberDeclension(number, one, two, five) {
|
||||
if (number > 10 && [11, 12, 13, 14].includes(number%100)) return five;
|
||||
let last_num = number%10;
|
||||
if (last_num == 1) return one;
|
||||
if ([2,3,4].includes(last_num)) return two;
|
||||
if ([5,6,7,8,9, 0].includes(last_num)) return five;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue