mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
Add HTTP client wrapper and upgrade Axios to v1 (#594)
* refactor: add HTTP client wrapper and upgrade axios to v1 Introduce a thin HTTP wrapper (resources/scripts/http) that centralizes axios configuration, interceptors, and auth header injection. All 43 files now import from the wrapper instead of axios directly, making future library swaps a single-file change. Upgrade axios from 0.30.0 to 1.14.0. * fix: restore window.Ls assignment removed during axios refactor company.js uses window.Ls.set() to persist selected company, which broke after the axios plugin (that set window.Ls) was deleted.
This commit is contained in:
committed by
GitHub
parent
a38f09cf7b
commit
691178857f
12
resources/scripts/admin/stores/category.js
vendored
12
resources/scripts/admin/stores/category.js
vendored
@@ -1,4 +1,4 @@
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
import { handleError } from '@/scripts/helpers/error-handling'
|
||||
@@ -27,7 +27,7 @@ export const useCategoryStore = (useWindow = false) => {
|
||||
actions: {
|
||||
fetchCategories(params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/categories`, { params })
|
||||
.then((response) => {
|
||||
this.categories = response.data.data
|
||||
@@ -42,7 +42,7 @@ export const useCategoryStore = (useWindow = false) => {
|
||||
|
||||
fetchCategory(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.get(`/api/v1/categories/${id}`)
|
||||
.then((response) => {
|
||||
this.currentCategory = response.data.data
|
||||
@@ -57,7 +57,7 @@ export const useCategoryStore = (useWindow = false) => {
|
||||
|
||||
addCategory(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post('/api/v1/categories', data)
|
||||
.then((response) => {
|
||||
this.categories.push(response.data.data)
|
||||
@@ -77,7 +77,7 @@ export const useCategoryStore = (useWindow = false) => {
|
||||
|
||||
updateCategory(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.put(`/api/v1/categories/${data.id}`, data)
|
||||
.then((response) => {
|
||||
if (response.data) {
|
||||
@@ -104,7 +104,7 @@ export const useCategoryStore = (useWindow = false) => {
|
||||
|
||||
deleteCategory(id) {
|
||||
return new Promise((resolve) => {
|
||||
axios
|
||||
http
|
||||
.delete(`/api/v1/categories/${id}`)
|
||||
.then((response) => {
|
||||
let index = this.categories.findIndex(
|
||||
|
||||
Reference in New Issue
Block a user