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:
@@ -32,9 +32,15 @@ AniWorld.NFOManager = (function() {
|
||||
}
|
||||
);
|
||||
|
||||
if (response && response.message) {
|
||||
AniWorld.UI.showToast(response.message || 'NFO created successfully', 'success');
|
||||
return response;
|
||||
if (!response) {
|
||||
throw new Error('Failed to create NFO');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.message) {
|
||||
AniWorld.UI.showToast(data.message || 'NFO created successfully', 'success');
|
||||
return data;
|
||||
} else {
|
||||
throw new Error('Failed to create NFO');
|
||||
}
|
||||
@@ -66,9 +72,15 @@ AniWorld.NFOManager = (function() {
|
||||
}
|
||||
);
|
||||
|
||||
if (response && response.message) {
|
||||
AniWorld.UI.showToast(response.message || 'NFO updated successfully', 'success');
|
||||
return response;
|
||||
if (!response) {
|
||||
throw new Error('Failed to refresh NFO');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.message) {
|
||||
AniWorld.UI.showToast(data.message || 'NFO updated successfully', 'success');
|
||||
return data;
|
||||
} else {
|
||||
throw new Error('Failed to refresh NFO');
|
||||
}
|
||||
@@ -97,8 +109,14 @@ AniWorld.NFOManager = (function() {
|
||||
`/api/nfo/${encodeURIComponent(seriesKey)}/content`
|
||||
);
|
||||
|
||||
if (response && response.content) {
|
||||
return response;
|
||||
if (!response) {
|
||||
throw new Error('No NFO data available');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.content) {
|
||||
return data;
|
||||
} else {
|
||||
throw new Error('No NFO data available');
|
||||
}
|
||||
@@ -200,8 +218,14 @@ AniWorld.NFOManager = (function() {
|
||||
try {
|
||||
const response = await AniWorld.ApiClient.request('/api/nfo/missing');
|
||||
|
||||
if (response && response.series) {
|
||||
return response;
|
||||
if (!response) {
|
||||
throw new Error('Failed to get series without NFO');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.series) {
|
||||
return data;
|
||||
} else {
|
||||
throw new Error('Failed to get series without NFO');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user