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)
  }
}
