mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 11:14:06 +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/customer/stores/auth.js
vendored
12
resources/scripts/customer/stores/auth.js
vendored
@@ -1,5 +1,5 @@
|
||||
const { defineStore } = window.pinia
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
import router from '@/scripts/customer/customer-router'
|
||||
import { handleError } from '@/scripts/customer/helpers/error-handling'
|
||||
@@ -20,9 +20,9 @@ export const useAuthStore = defineStore({
|
||||
login(data) {
|
||||
const notificationStore = useNotificationStore(true)
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/sanctum/csrf-cookie').then((response) => {
|
||||
http.get('/sanctum/csrf-cookie').then((response) => {
|
||||
if (response) {
|
||||
axios
|
||||
http
|
||||
.post(`/${data.company}/customer/login`, data)
|
||||
.then((response) => {
|
||||
notificationStore.showNotification({
|
||||
@@ -47,7 +47,7 @@ export const useAuthStore = defineStore({
|
||||
forgotPassword(data) {
|
||||
const notificationStore = useNotificationStore(true)
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/${data.company}/customer/auth/password/email`, data)
|
||||
|
||||
.then((response) => {
|
||||
@@ -75,7 +75,7 @@ export const useAuthStore = defineStore({
|
||||
|
||||
resetPassword(data, company) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/api/v1/${company}/customer/auth/reset/password`, data)
|
||||
|
||||
.then((response) => {
|
||||
@@ -102,7 +102,7 @@ export const useAuthStore = defineStore({
|
||||
|
||||
logout(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
http
|
||||
.post(`/${data}/customer/logout`)
|
||||
.then((response) => {
|
||||
const notificationStore = useNotificationStore()
|
||||
|
||||
Reference in New Issue
Block a user