From b5bd672f446b0a6c8045e996f095826211bad772 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Mon, 3 Jan 2022 18:38:32 +0100 Subject: [PATCH] More accurate checks for what response contains and throws error if it does not exist. --- seasoned_api/src/plex/plex.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/seasoned_api/src/plex/plex.js b/seasoned_api/src/plex/plex.js index ef377fc..9eb1b29 100644 --- a/seasoned_api/src/plex/plex.js +++ b/seasoned_api/src/plex/plex.js @@ -30,6 +30,16 @@ const matchingTitleAndYear = (plex, tmdb) => { }; const successfullResponse = response => { + if (response && response["MediaContainer"]) return response; + + if ( + response == null || + response["status"] == null || + response["statusText"] == null + ) { + throw Error("Unable to decode response"); + } + const { status, statusText } = response; if (status === 200) {