From 63e36b0af65e2d5130c2190fe9902bdd11945445 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 29 Nov 2024 19:42:04 +0600 Subject: [PATCH 1/3] updt: genre api calling converted --- frontend/src/services/v1/genreAPIService.js | 34 +++++++++++++------ .../src/store/modules/genres/genreDetails.js | 4 +-- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/frontend/src/services/v1/genreAPIService.js b/frontend/src/services/v1/genreAPIService.js index 745bfac..39325ce 100644 --- a/frontend/src/services/v1/genreAPIService.js +++ b/frontend/src/services/v1/genreAPIService.js @@ -6,17 +6,29 @@ const API_BASE_URL = process.env.VUE_APP_BACKEND_URL const content = 'genre' const version = 'v1' -export default { - async fetchV1GenreDetails (id = null) { - const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` - console.log('Genre Details API:', URL) +export const fetchV1GenreDetails = async (id = null) => { + const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` + console.log('Genre Details API:', URL) - try { - const response = await axios.get(URL) - return response.data - } catch (error) { - console.error('Error fetching genre:', error) - throw error - } + try { + const response = await axios.get(URL) + return response.data + } catch (error) { + console.error('Error fetching genre:', error) + throw error } } +// export default { +// async fetchV1GenreDetails (id = null) { +// const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` +// console.log('Genre Details API:', URL) + +// try { +// const response = await axios.get(URL) +// return response.data +// } catch (error) { +// console.error('Error fetching genre:', error) +// throw error +// } +// } +// } diff --git a/frontend/src/store/modules/genres/genreDetails.js b/frontend/src/store/modules/genres/genreDetails.js index c7896a3..9eb249d 100644 --- a/frontend/src/store/modules/genres/genreDetails.js +++ b/frontend/src/store/modules/genres/genreDetails.js @@ -1,6 +1,6 @@ // src/store/modules/genreDetails.js -import genreAPIService from '@/services/v1/genreAPIService' +import { fetchV1GenreDetails } from '@/services/v1/genreAPIService' export default { state: { @@ -29,7 +29,7 @@ export default { commit('SET_LOADING', true) commit('SET_ERROR', null) try { - const response = await genreAPIService.fetchV1GenreDetails(genreId) + const response = await fetchV1GenreDetails(genreId) commit('SET_GENRE_DETAILS', response) } catch (error) { const errorMessages = [] From 1f2f503b52aa27a94897a217949c107d32632250 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 29 Nov 2024 19:45:03 +0600 Subject: [PATCH 2/3] updt: topic api calling converted --- frontend/src/services/v1/genreAPIService.js | 14 ------------- frontend/src/services/v1/topicAPIService.js | 20 +++++++++---------- .../src/store/modules/topics/topicDetails.js | 4 ++-- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/frontend/src/services/v1/genreAPIService.js b/frontend/src/services/v1/genreAPIService.js index 39325ce..5d60801 100644 --- a/frontend/src/services/v1/genreAPIService.js +++ b/frontend/src/services/v1/genreAPIService.js @@ -18,17 +18,3 @@ export const fetchV1GenreDetails = async (id = null) => { throw error } } -// export default { -// async fetchV1GenreDetails (id = null) { -// const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` -// console.log('Genre Details API:', URL) - -// try { -// const response = await axios.get(URL) -// return response.data -// } catch (error) { -// console.error('Error fetching genre:', error) -// throw error -// } -// } -// } diff --git a/frontend/src/services/v1/topicAPIService.js b/frontend/src/services/v1/topicAPIService.js index e1df2f3..3c3b21a 100644 --- a/frontend/src/services/v1/topicAPIService.js +++ b/frontend/src/services/v1/topicAPIService.js @@ -6,17 +6,15 @@ const API_BASE_URL = process.env.VUE_APP_BACKEND_URL const content = 'topic' const version = 'v1' -export default { - async fetchV1TopicDetails (id = null) { - const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` - console.log('topic Details API:', URL) +export const fetchV1TopicDetails = async (id = null) => { + const URL = `${API_BASE_URL}/book/${version}/${content}/${id}/` + console.log('topic Details API:', URL) - try { - const response = await axios.get(URL) - return response.data - } catch (error) { - console.error('Error fetching topic:', error) - throw error - } + try { + const response = await axios.get(URL) + return response.data + } catch (error) { + console.error('Error fetching topic:', error) + throw error } } diff --git a/frontend/src/store/modules/topics/topicDetails.js b/frontend/src/store/modules/topics/topicDetails.js index f22c809..8d523ef 100644 --- a/frontend/src/store/modules/topics/topicDetails.js +++ b/frontend/src/store/modules/topics/topicDetails.js @@ -1,6 +1,6 @@ // src/store/modules/topicDetails.js -import topicAPIService from '@/services/v1/topicAPIService' +import { fetchV1TopicDetails } from '@/services/v1/topicAPIService' export default { state: { @@ -29,7 +29,7 @@ export default { commit('SET_LOADING', true) commit('SET_ERROR', null) try { - const response = await topicAPIService.fetchV1TopicDetails(topicId) + const response = await fetchV1TopicDetails(topicId) commit('SET_TOPIC_DETAILS', response) } catch (error) { const errorMessages = [] From 4545966043e07f83fabcf29ec151e54fdff0cc31 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 29 Nov 2024 19:48:47 +0600 Subject: [PATCH 3/3] final touch --- frontend/src/services/v1/bookAPIService.js | 8 ++++---- frontend/src/services/v1/genreAPIService.js | 4 ++-- frontend/src/services/v1/topicAPIService.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/services/v1/bookAPIService.js b/frontend/src/services/v1/bookAPIService.js index 861198f..d663feb 100644 --- a/frontend/src/services/v1/bookAPIService.js +++ b/frontend/src/services/v1/bookAPIService.js @@ -1,6 +1,6 @@ // src/services/v1/bookAPIService.js -import axios from 'axios' +import api from '@/services/axiosInstance' const API_BASE_URL = process.env.VUE_APP_BACKEND_URL const content = 'book' @@ -22,7 +22,7 @@ export default { console.log('Books API:', URL, page, pageSize) try { - const response = await axios.get(URL) + const response = await api.get(URL) return response.data } catch (error) { console.error('Error fetching books:', error) @@ -34,7 +34,7 @@ export default { console.log('Book Details API:', URL) try { - const response = await axios.get(URL) + const response = await api.get(URL) return response.data } catch (error) { console.error('Error fetching book:', error) @@ -53,7 +53,7 @@ export default { console.log('Search Books API:', URL) try { - const response = await axios.get(URL) + const response = await api.get(URL) console.log(response.data) return response.data } catch (error) { diff --git a/frontend/src/services/v1/genreAPIService.js b/frontend/src/services/v1/genreAPIService.js index 5d60801..6eac43f 100644 --- a/frontend/src/services/v1/genreAPIService.js +++ b/frontend/src/services/v1/genreAPIService.js @@ -1,6 +1,6 @@ // src/services/v1/genreAPIService.js -import axios from 'axios' +import api from '@/services/axiosInstance' const API_BASE_URL = process.env.VUE_APP_BACKEND_URL const content = 'genre' @@ -11,7 +11,7 @@ export const fetchV1GenreDetails = async (id = null) => { console.log('Genre Details API:', URL) try { - const response = await axios.get(URL) + const response = await api.get(URL) return response.data } catch (error) { console.error('Error fetching genre:', error) diff --git a/frontend/src/services/v1/topicAPIService.js b/frontend/src/services/v1/topicAPIService.js index 3c3b21a..0737c81 100644 --- a/frontend/src/services/v1/topicAPIService.js +++ b/frontend/src/services/v1/topicAPIService.js @@ -1,6 +1,6 @@ // src/services/v1/topicAPIService.js -import axios from 'axios' +import api from '@/services/axiosInstance' const API_BASE_URL = process.env.VUE_APP_BACKEND_URL const content = 'topic' @@ -11,7 +11,7 @@ export const fetchV1TopicDetails = async (id = null) => { console.log('topic Details API:', URL) try { - const response = await axios.get(URL) + const response = await api.get(URL) return response.data } catch (error) { console.error('Error fetching topic:', error)