Remvove null values from showData response

This commit is contained in:
Mike Rode
2019-09-02 09:16:31 -05:00
parent 5f0a7978b3
commit b701e8ba62
2 changed files with 4 additions and 13 deletions

View File

@@ -13,18 +13,7 @@ const similarMedia = async (req, res) => {
media,
);
console.log('tdaw response test--', response);
const jsonLibrary = await models.PlexLibrary.findAll({
userId: req.user.id,
type: 'show',
});
// Use Sonarr list instead
const libraryTitles = jsonLibrary.map(show => show.title.toLowerCase());
const filteredResponse = response.filter(
show => !libraryTitles.includes(show.name.toLowerCase()),
);
console.log('final----response', filteredResponse);
res.json(filteredResponse);
res.json(response);
} catch (error) {
helpers.handleError(res, tdawApi.name);
}

View File

@@ -49,9 +49,11 @@ const similarMedia = async function(req, mediaName, mediaType) {
};
const getShowData = async filteredResponse => {
return await Promise.all(
const showData = await Promise.all(
filteredResponse.map(show => movieDbApi.searchTv(show.Name)),
);
console.log('mapped show data', showData);
return showData.filter(obj => obj);
};
const qlooMediaId = async (mediaName, mediaType) => {