fix(servarr): handle baseurl error when testing connection (#2294)

* fix(servarr): handle base url error when testing servarr connection

* fix(servarr): suggested changes
pull/2332/head
Danshil Kokil Mungur 3 years ago committed by GitHub
parent f284e4ab97
commit 93b5ea20ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,7 +46,10 @@ radarrRoutes.post<
url: RadarrAPI.buildUrl(req.body, '/api/v3'), url: RadarrAPI.buildUrl(req.body, '/api/v3'),
}); });
const { urlBase } = await radarr.getSystemStatus(); const urlBase = await radarr
.getSystemStatus()
.then((value) => value.urlBase)
.catch(() => req.body.baseUrl);
const profiles = await radarr.getProfiles(); const profiles = await radarr.getProfiles();
const folders = await radarr.getRootFolders(); const folders = await radarr.getRootFolders();
const tags = await radarr.getTags(); const tags = await radarr.getTags();
@ -58,10 +61,7 @@ radarrRoutes.post<
path: folder.path, path: folder.path,
})), })),
tags, tags,
urlBase: urlBase,
req.body.baseUrl && req.body.baseUrl !== '/'
? req.body.baseUrl
: urlBase,
}); });
} catch (e) { } catch (e) {
logger.error('Failed to test Radarr', { logger.error('Failed to test Radarr', {

@ -42,7 +42,10 @@ sonarrRoutes.post('/test', async (req, res, next) => {
url: SonarrAPI.buildUrl(req.body, '/api/v3'), url: SonarrAPI.buildUrl(req.body, '/api/v3'),
}); });
const { urlBase } = await sonarr.getSystemStatus(); const urlBase = await sonarr
.getSystemStatus()
.then((value) => value.urlBase)
.catch(() => req.body.baseUrl);
const profiles = await sonarr.getProfiles(); const profiles = await sonarr.getProfiles();
const folders = await sonarr.getRootFolders(); const folders = await sonarr.getRootFolders();
const languageProfiles = await sonarr.getLanguageProfiles(); const languageProfiles = await sonarr.getLanguageProfiles();
@ -56,10 +59,7 @@ sonarrRoutes.post('/test', async (req, res, next) => {
})), })),
languageProfiles, languageProfiles,
tags, tags,
urlBase: urlBase,
req.body.baseUrl && req.body.baseUrl !== '/'
? req.body.baseUrl
: urlBase,
}); });
} catch (e) { } catch (e) {
logger.error('Failed to test Sonarr', { logger.error('Failed to test Sonarr', {

Loading…
Cancel
Save