Fix autocomplete
This commit is contained in:
parent
d8eaaba9c9
commit
458f4a66ee
2 changed files with 13 additions and 1 deletions
12
src/app/search/autocompleter/route.ts
Normal file
12
src/app/search/autocompleter/route.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { NextRequest } from "next/server";
|
||||
import { stringify } from "node:querystring";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
return Response.json(
|
||||
await fetch(
|
||||
`https://s.abtmtr.link/autocompleter?${stringify({
|
||||
q: request.nextUrl.searchParams.get("q")
|
||||
})}`
|
||||
).then(x => x.json())
|
||||
);
|
||||
}
|
|
@ -25,7 +25,7 @@ export default function Searchbar({value}:{value?:string}) {
|
|||
async function executeAC(e:FormEvent<HTMLInputElement>) {
|
||||
const target = e.target as HTMLInputElement;
|
||||
console.log(target.value);
|
||||
const rows = await fetch(`https://s.abtmtr.link/autocompleter?${stringify({
|
||||
const rows = await fetch(`/search/autocompleter?${stringify({
|
||||
q: target.value
|
||||
})}`).then(x => x.json());
|
||||
if (rows == null) return;
|
||||
|
|
Loading…
Reference in a new issue