From 022f26f0a3aa8c31b65813418ba3c0d5e57563bc Mon Sep 17 00:00:00 2001 From: Nevin Morgan Date: Thu, 19 Sep 2024 13:11:30 -0400 Subject: [PATCH] Service object updates (#88) * remove barrel file for api service layer * update return signatures for clarity in api service layer * remove references to barrel file --- resources/js/api/ConceptService.js | 10 +++++----- resources/js/api/ConceptSourceService.js | 12 ++++++------ resources/js/api/TermService.js | 12 ++++++------ resources/js/api/index.js | 5 ----- resources/js/components/Concept/Create.vue | 2 +- resources/js/components/Concept/List.vue | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 resources/js/api/index.js diff --git a/resources/js/api/ConceptService.js b/resources/js/api/ConceptService.js index f5e7e49..0203d2c 100644 --- a/resources/js/api/ConceptService.js +++ b/resources/js/api/ConceptService.js @@ -1,7 +1,7 @@ import axios from 'axios'; const apiClient = axios.create({ - baseURL: `api/concepts`, + baseURL: `/api/concepts`, }); export default { @@ -17,7 +17,7 @@ export default { }); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -26,7 +26,7 @@ export default { const { data } = await apiClient.get(`/${conceptId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -35,7 +35,7 @@ export default { const { data } = await apiClient.post('', conceptData); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -44,7 +44,7 @@ export default { const { data } = await apiClient.delete(`/${conceptId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, }; diff --git a/resources/js/api/ConceptSourceService.js b/resources/js/api/ConceptSourceService.js index b5524ae..648a12a 100644 --- a/resources/js/api/ConceptSourceService.js +++ b/resources/js/api/ConceptSourceService.js @@ -1,7 +1,7 @@ import axios from 'axios'; const apiClient = axios.create({ - baseURL: `api/concept_sources`, + baseURL: `/api/concept_sources`, }); export default { @@ -17,7 +17,7 @@ export default { }); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -26,7 +26,7 @@ export default { const { data } = await apiClient.get(`/${conceptSourceId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -35,7 +35,7 @@ export default { const { data } = await apiClient.post('', conceptSourceData); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -47,7 +47,7 @@ export default { ); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -56,7 +56,7 @@ export default { const { data } = await apiClient.delete(`/${conceptSourceId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, }; diff --git a/resources/js/api/TermService.js b/resources/js/api/TermService.js index f7084aa..ededbfa 100644 --- a/resources/js/api/TermService.js +++ b/resources/js/api/TermService.js @@ -1,7 +1,7 @@ import axios from 'axios'; const apiClient = axios.create({ - baseURL: `api/terms`, + baseURL: `/api/terms`, }); export default { @@ -17,7 +17,7 @@ export default { }); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -26,7 +26,7 @@ export default { const { data } = await apiClient.get(`/${termId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -35,7 +35,7 @@ export default { const { data } = await apiClient.post('', termData); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -44,7 +44,7 @@ export default { const { data } = await apiClient.patch(`/${termId}`, termData); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, @@ -53,7 +53,7 @@ export default { const { data } = await apiClient.delete(`/${termId}`); return [null, data]; } catch (error) { - return [error]; + return [error, null]; } }, }; diff --git a/resources/js/api/index.js b/resources/js/api/index.js deleted file mode 100644 index 69ddea4..0000000 --- a/resources/js/api/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import ConceptService from './ConceptService'; -import ConceptSourceService from './ConceptSourceService'; -import TermService from './TermService'; - -export { ConceptService, ConceptSourceService, TermService }; diff --git a/resources/js/components/Concept/Create.vue b/resources/js/components/Concept/Create.vue index ec7692e..1840afd 100644 --- a/resources/js/components/Concept/Create.vue +++ b/resources/js/components/Concept/Create.vue @@ -87,7 +87,7 @@ import { BFormInvalidFeedback, } from 'bootstrap-vue'; import { categories } from '../../config/catgegories'; -import { ConceptService } from '../../api'; +import ConceptService from '../../api/ConceptService'; export default { data() { diff --git a/resources/js/components/Concept/List.vue b/resources/js/components/Concept/List.vue index d223016..5f28ecc 100644 --- a/resources/js/components/Concept/List.vue +++ b/resources/js/components/Concept/List.vue @@ -87,7 +87,7 @@ import { BPagination, BTable, } from 'bootstrap-vue'; -import { ConceptService } from '../../api'; +import ConceptService from '../../api/ConceptService'; import { sortBy } from 'lodash'; export default {