1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetch } from "https://esm.town/v/std/fetch";
export const getTmdbTrendingMovies = async (
accessToken: string,
{ timeWindow, language } = { timeWindow: "week", language: "en-US" },
) => {
const url =
`https://api.themoviedb.org/3/trending/movie/${timeWindow}?language=${language}`;
const options = {
method: "GET",
headers: {
accept: "application/json",
Authorization: `Bearer ${accessToken}`,
},
};
const res = await (await fetch(url, options)).json();
return res.results;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
1
nicolasgiaco avatar

Nice code dude ! You rock 🫶

October 23, 2023