diff --git a/frontend/src/services/v1/genreAPIService.js b/frontend/src/services/v1/genreAPIService.js index 745bfac..6eac43f 100644 --- a/frontend/src/services/v1/genreAPIService.js +++ b/frontend/src/services/v1/genreAPIService.js @@ -1,22 +1,20 @@ // 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' 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 api.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..0737c81 100644 --- a/frontend/src/services/v1/topicAPIService.js +++ b/frontend/src/services/v1/topicAPIService.js @@ -1,22 +1,20 @@ // 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' 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 api.get(URL) + return response.data + } catch (error) { + console.error('Error fetching topic:', 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 = [] 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 = []