This commit is contained in:
Wise Colt
2020-03-31 02:05:55 +03:00
parent 76080df633
commit 83f89695c9
2 changed files with 23 additions and 18 deletions

View File

@@ -6,31 +6,35 @@ module.exports.getDetails = function (detailsId, movieOrTv, tmdbApiKey, language
if (movieOrTv == 'movie' || movieOrTv == 'tv') {
const detailURL = config.theMovieDbURL + movieOrTv + '/' + detailsId + '?api_key=' + tmdbApiKey + '&language=' + language;
request(detailURL, (err, resultBody, body) => {
if (resultBody != '') {
const getJson = JSON.parse(resultBody.body);
const getJson = JSON.parse(resultBody.body);
if (getJson.status_code > 1) {
// if wrong api key error
const error = 'tmdb get detail wrong api key error';
const result = null;
cb(error, result);
}
else {
if (err) {
// if thmdb api connection error
const error = 'tmdb get detail api connection error';
if (getJson.status_code > 1) {
// if wrong api key error
const error = 'tmdb get detail wrong api key error';
const result = null;
cb(error, result);
}
else {
const error = null;
const result = getJson;
cb(error, result);
if (err) {
// if thmdb api connection error
const error = 'tmdb get detail api connection error';
const result = null;
cb(error, result);
}
else {
const error = null;
const result = getJson;
cb(error, result);
}
}
} else {
const error = 'tmdb get detail api connection error';
const result = null;
cb(error, result);
}
});
}
else {