diff --git a/.inscode b/.inscode index 70c7853df0c162981ebd7cf119d909c807920531..9fec9576d482baaf90d2f47230ce9133cfce99d4 100644 --- a/.inscode +++ b/.inscode @@ -1,4 +1,5 @@ run = "npm i && npm run dev" +language = "node" [deployment] build = "npm i && npm run build" @@ -8,3 +9,6 @@ run = "npm run preview" PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/src/utils/https.ts b/src/utils/https.ts new file mode 100644 index 0000000000000000000000000000000000000000..2bfc7242fbd41da8aeb18af0149fb8891e71cd00 --- /dev/null +++ b/src/utils/https.ts @@ -0,0 +1,21 @@ +import { + AXIOS +} from './interceptors'; +export const method = { + get(addr: string) { + return AXIOS.get(addr); + }, + post(addr: string, datas: { [key: string]: any }) { + return AXIOS.post(addr, + datas, + ); + }, + put(addr: string, datas: { [key: string]: any }) { + return AXIOS.put(addr, { + ...datas, + }); + }, + delete(addr: string, id: number | string) { + return AXIOS.delete(`${addr}/${id}`); + } +} diff --git a/src/utils/interceptors.ts b/src/utils/interceptors.ts new file mode 100644 index 0000000000000000000000000000000000000000..44a04e1f4f3a6e73f60bf57005fb6953ad5eaf21 --- /dev/null +++ b/src/utils/interceptors.ts @@ -0,0 +1,26 @@ +import axios from "axios"; + +export const AXIOS = axios.create({ + // baseURL: "/login/api", + baseURL: "" +}) + +AXIOS.interceptors.request.use( + function(response: any) { + response.headers["Authorization"] = sessionStorage.getItem("token"); + return response; + }, + function(error) { + console.log(error) + return false; + } +) + +AXIOS.interceptors.response.use( + function(request) { + return request.data + }, + function(error) { + return Promise.reject(error); + } +) \ No newline at end of file