Fix incorrect handling of non-JSON responses in APIs
This commit is contained in:
parent
76f4fd68f8
commit
f9e4a50795
|
@ -31,14 +31,16 @@ http.interceptors.response.use((resp) => {
|
||||||
store.commit('setLoading', { model: resp.config.loading, status: false });
|
store.commit('setLoading', { model: resp.config.loading, status: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = { ...resp.data.data };
|
|
||||||
if (!resp.config.preserveCase) {
|
let data = {};
|
||||||
if (resp.data && resp.data.data) {
|
|
||||||
if (typeof resp.data.data === 'object') {
|
if (typeof resp.data.data === 'object') {
|
||||||
|
data = { ...resp.data.data };
|
||||||
|
if (!resp.config.preserveCase) {
|
||||||
// Transform field case.
|
// Transform field case.
|
||||||
data = humps.camelizeKeys(resp.data.data);
|
data = humps.camelizeKeys(resp.data.data);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
data = resp.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the API response for a model.
|
// Store the API response for a model.
|
||||||
|
@ -137,7 +139,8 @@ export const importSubscribers = (data) => http.post('/api/import/subscribers',
|
||||||
|
|
||||||
export const getImportStatus = () => http.get('/api/import/subscribers');
|
export const getImportStatus = () => http.get('/api/import/subscribers');
|
||||||
|
|
||||||
export const getImportLogs = () => http.get('/api/import/subscribers/logs');
|
export const getImportLogs = async () => http.get('/api/import/subscribers/logs',
|
||||||
|
{ preserveCase: true });
|
||||||
|
|
||||||
export const stopImport = () => http.delete('/api/import/subscribers');
|
export const stopImport = () => http.delete('/api/import/subscribers');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue