movie-explorer/src/objects/tmdb.tsx

25 lines
572 B
TypeScript
Raw Normal View History

2024-05-02 20:47:28 +00:00
import axios from 'axios'
import * as auth from '../auth.json';
import { Config } from '../App';
const tmdb = axios.create({
baseURL: `https://api.themoviedb.org/3/movie`,
headers: {
Authorization: 'Bearer ' + auth.token,
'Content-Type': 'application/json',
}
})
export default {
getPopular: async function({ language, region }: Config, callback: Function) {
let res = await tmdb.get('/popular?language=en-US&page=1',
{
params: {
language,
region
}
})
res = res.data.results
callback(res)
}
}