initial commit

This commit is contained in:
Blake Joynes
2021-05-15 00:22:10 -04:00
commit d800f56ee6
20 changed files with 697 additions and 0 deletions

22
src/api.ts Normal file
View File

@@ -0,0 +1,22 @@
import fetch from 'node-fetch';
const BASE_URL_V3 = 'https://api.themoviedb.org/3'
export class Api{
constructor(private accessToken: string){
this.accessToken = accessToken
}
async get<T>(path: string): Promise<T> {
const response = await fetch(`${BASE_URL_V3}${path}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${this.accessToken}`,
'Content-Type': 'application/json;charset=utf-8'
},
});
return await response.json() as T;
}
}