add error. linting

This commit is contained in:
Blake Joynes
2024-01-15 11:59:48 -05:00
parent 6a68e9973b
commit 1146ca8ad2
14 changed files with 135 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
import fetch from 'cross-fetch';
import { parseOptions } from './utils';
import { ErrorResponse } from './types';
const BASE_URL_V3 = 'https://api.themoviedb.org/3';
@@ -17,6 +18,11 @@ export class Api {
'Content-Type': 'application/json;charset=utf-8',
},
});
if (!response.ok) {
return Promise.reject((await response.json()) as ErrorResponse);
}
return (await response.json()) as T;
}
}