20 lines
460 B
TypeScript
20 lines
460 B
TypeScript
"use server";
|
|
|
|
import { SearchResult } from "./types";
|
|
|
|
const fetchTmbd = async (url: string) => {
|
|
const response = await fetch(url, {
|
|
headers: {
|
|
Authorization: `Bearer ${process.env.TMDB_BEARER}`,
|
|
},
|
|
});
|
|
const data = await response.json();
|
|
return data;
|
|
};
|
|
|
|
const url = "https://api.themoviedb.org/3";
|
|
|
|
export async function search(query: string): Promise<SearchResult> {
|
|
return await fetchTmbd(`${url}/search/movie?query=${query}`);
|
|
}
|