From 13532cba1457f6435575351408a1c759c0e7d951 Mon Sep 17 00:00:00 2001 From: Paul Nettleton Date: Tue, 29 Nov 2022 12:23:02 -0600 Subject: [PATCH] Update SearchController.js to respond with objects Changes: - `findCovers` (GET /api/search/covers) - `findBooks` (GET /api/search/books) - `findPodcasts` (GET /api/search/podcast) --- server/controllers/SearchController.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/controllers/SearchController.js b/server/controllers/SearchController.js index 05f0cff6..fa61b52d 100644 --- a/server/controllers/SearchController.js +++ b/server/controllers/SearchController.js @@ -7,8 +7,9 @@ class SearchController { var provider = req.query.provider || 'google' var title = req.query.title || '' var author = req.query.author || '' - var results = await this.bookFinder.search(provider, title, author) - res.json(results) + res.json({ + results: await this.bookFinder.search(provider, title, author) + }) } async findCovers(req, res) { @@ -23,13 +24,16 @@ class SearchController { var result = null if (podcast) result = await this.podcastFinder.findCovers(query.title) else result = await this.bookFinder.findCovers(query.provider || 'google', query.title, query.author || null) - res.json(result) + res.json({ + results: result + }) } async findPodcasts(req, res) { var term = req.query.term - var results = await this.podcastFinder.search(term) - res.json(results) + res.json({ + results: await this.podcastFinder.search(term) + }) } async findAuthor(req, res) {