ray-template/js/instance-COhWfrSq.js

2 lines
1.9 KiB
JavaScript

import{K as t,N as n,e as R,O as q}from"./hooks-DtYdZWXJ.js";import"./dayjs@1.11.10-C8LoRVP6.js";import"./print-js@1.6.0-BdoEj60G.js";import"./vue-hooks-plus@2.2.0_vue@3.4.30-DdMBTcyt.js";import"./lodash@4.17.21-Cw59kuJw.js";import"./js-cookie@3.0.5-Z_8Sd105.js";import"./screenfull@5.2.0-DmMZCkhi.js";import{g as d}from"./utils-BmI4YPvf.js";import"./currency.js@2.0.4-9OAR_aOO.js";const A=(e,r)=>{t.removePendingRequest(e)},y=(e,r)=>{t.removePendingRequest(e)},p={implementResponseInterceptorArray:[A],implementResponseInterceptorErrorArray:[y]},{setImplement:m}=n(),E=()=>{const{implementResponseInterceptorArray:e}=p;m("implementResponseInterceptorArray",e,"ok")},k=()=>{const{implementResponseInterceptorErrorArray:e}=p;m("implementResponseInterceptorErrorArray",e,"error")},P=(e,r)=>{t.removePendingRequest(e),t.addPendingRequest(e)},v=(e,r)=>{t.removePendingRequest(e)},g=(e,r)=>{if(e){const o=e.headers;r.forEach(s=>{o[s.key]=s.value})}},C=(e,r)=>{const o=d(R.token);return e.url,{key:"X-TOKEN",value:o}},f=(e,r)=>{g(e,[C(e),{key:"Demo-Header-Key",value:"Demo Header Value"}])},c={implementRequestInterceptorArray:[f,P],implementRequestInterceptorErrorArray:[v]},{setImplement:a}=n(),H=()=>{const{implementRequestInterceptorArray:e}=c;a("implementRequestInterceptorArray",e,"ok")},j=()=>{const{implementRequestInterceptorErrorArray:e}=c;a("implementRequestInterceptorErrorArray",e,"error")},i=axios.create(q),{createAxiosInstance:u,beforeFetch:l,fetchError:I}=n();i.interceptors.request.use(e=>(u(e,"requestInstance"),H(),l("requestInstance","implementRequestInterceptorArray","ok"),e),e=>(j(),I("requestError",e,"implementRequestInterceptorErrorArray"),Promise.reject(e)));i.interceptors.response.use(e=>{u(e,"responseInstance"),E(),l("responseInstance","implementResponseInterceptorArray","ok");const{data:r}=e;return Promise.resolve(r)},e=>(k(),I("responseError",e,"implementResponseInterceptorErrorArray"),Promise.reject(e)));export{i as s};