Fix JSON parsing in NFO JavaScript modules
- Add response.json() calls in nfo-manager.js for all API calls - Add response.json() calls in nfo-config.js for all API calls - Fix createNFO, refreshNFO, viewNFO, getSeriesWithoutNFO functions - Fix load and testTMDBConnection functions - All API responses must be parsed before accessing properties
This commit is contained in:
@@ -18,7 +18,13 @@ AniWorld.NFOConfig = (function() {
|
||||
*/
|
||||
async function load() {
|
||||
try {
|
||||
const config = await AniWorld.ApiClient.request(API.CONFIG);
|
||||
const response = await AniWorld.ApiClient.request(API.CONFIG);
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Failed to load configuration');
|
||||
}
|
||||
|
||||
const config = await response.json();
|
||||
|
||||
if (config && config.nfo) {
|
||||
const nfo = config.nfo;
|
||||
@@ -148,10 +154,16 @@ AniWorld.NFOConfig = (function() {
|
||||
}
|
||||
);
|
||||
|
||||
if (response && response.valid) {
|
||||
if (!response) {
|
||||
throw new Error('No response from server');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.valid) {
|
||||
AniWorld.UI.showToast('TMDB API key is valid!', 'success');
|
||||
} else {
|
||||
const message = response && response.message ? response.message : 'Invalid API key';
|
||||
const message = data && data.message ? data.message : 'Invalid API key';
|
||||
AniWorld.UI.showToast('TMDB validation failed: ' + message, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user