diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index fe1af849..eeab3ce4 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -122,7 +122,7 @@ export default { return this.$store.state.globals.selectedMediaItems }, selectedMediaItemsArePlayable() { - return !this.selectedMediaItems.some(i => !i.hasTracks) + return !this.selectedMediaItems.some((i) => !i.hasTracks) }, userMediaProgress() { return this.$store.state.user.user.mediaProgress || [] @@ -164,12 +164,15 @@ export default { this.$store.commit('setProcessingBatch', true) const libraryItemIds = this.selectedMediaItems.map((i) => i.id) - const libraryItems = await this.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => { - const errorMsg = error.response.data || 'Failed to get items' - console.error(errorMsg, error) - this.$toast.error(errorMsg) - return [] - }) + const libraryItems = await this.$axios + .$post(`/api/items/batch/get`, { libraryItemIds }) + .then((res) => res.libraryItems) + .catch((error) => { + const errorMsg = error.response.data || 'Failed to get items' + console.error(errorMsg, error) + this.$toast.error(errorMsg) + return [] + }) if (!libraryItems.length) { this.$store.commit('setProcessingBatch', false) diff --git a/client/pages/batch/index.vue b/client/pages/batch/index.vue index 976005eb..fd5f6d89 100644 --- a/client/pages/batch/index.vue +++ b/client/pages/batch/index.vue @@ -96,11 +96,14 @@ export default { } const libraryItemIds = store.state.globals.selectedMediaItems.map((i) => i.id) - const libraryItems = await app.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => { - const errorMsg = error.response.data || 'Failed to get items' - console.error(errorMsg, error) - return [] - }) + const libraryItems = await app.$axios + .$post(`/api/items/batch/get`, { libraryItemIds }) + .then((res) => res.libraryItems) + .catch((error) => { + const errorMsg = error.response.data || 'Failed to get items' + console.error(errorMsg, error) + return [] + }) return { mediaType: libraryItems[0].mediaType, libraryItems diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index b6d649b1..7c3c9c08 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -308,17 +308,17 @@ class LibraryItemController { // POST: api/items/batch/get async batchGet(req, res) { - var libraryItemIds = req.body.libraryItemIds || [] + const libraryItemIds = req.body.libraryItemIds || [] if (!libraryItemIds.length) { return res.status(403).send('Invalid payload') } - var libraryItems = [] + const libraryItems = [] libraryItemIds.forEach((lid) => { const li = this.db.libraryItems.find(_li => _li.id === lid) if (li) libraryItems.push(li.toJSONExpanded()) }) res.json({ - libraryItems: libraryItems + libraryItems }) }