From 606334ffadbf919dc128f1e2a32fef8c327fa78e Mon Sep 17 00:00:00 2001 From: zhangchuanlong Date: Mon, 14 Mar 2022 16:36:21 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=9A=84axios=E5=AE=9E=E4=BE=8B=E5=88=AB?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/auth/index.js | 6 +++--- src/api/post/index.js | 12 ++++++------ src/api/user/index.js | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/auth/index.js b/src/api/auth/index.js index 13bc3a0..74c6082 100644 --- a/src/api/auth/index.js +++ b/src/api/auth/index.js @@ -1,7 +1,7 @@ -import { defAxios } from '@/utils/http' +import { defAxios as request } from '@/utils/http' export const login = (data) => { - return defAxios({ + return request({ url: '/auth/login', method: 'post', data, @@ -9,7 +9,7 @@ export const login = (data) => { } export const refreshToken = () => { - return defAxios({ + return request({ url: '/auth/refreshToken', method: 'post', }) diff --git a/src/api/post/index.js b/src/api/post/index.js index 3838abe..e06f12b 100644 --- a/src/api/post/index.js +++ b/src/api/post/index.js @@ -1,7 +1,7 @@ -import { defAxios } from '@/utils/http' +import { defAxios as request } from '@/utils/http' export function getPosts(data = {}) { - return defAxios({ + return request({ url: '/posts', method: 'get', data, @@ -9,7 +9,7 @@ export function getPosts(data = {}) { } export function getPostById({ id }) { - return defAxios({ + return request({ url: `/post/${id}`, method: 'get', }) @@ -17,14 +17,14 @@ export function getPostById({ id }) { export function savePost(id, data = {}) { if (id) { - return defAxios({ + return request({ url: `/post/${id}`, method: 'put', data, }) } - return defAxios({ + return request({ url: '/post', method: 'post', data, @@ -32,7 +32,7 @@ export function savePost(id, data = {}) { } export function deletePost(id) { - return defAxios({ + return request({ url: `/post/${id}`, method: 'delete', }) diff --git a/src/api/user/index.js b/src/api/user/index.js index 200d115..55c7c5f 100644 --- a/src/api/user/index.js +++ b/src/api/user/index.js @@ -1,7 +1,7 @@ -import { defAxios } from '@/utils/http' +import { defAxios as request } from '@/utils/http' export function getUsers(data = {}) { - return defAxios({ + return request({ url: '/users', method: 'get', data, @@ -10,12 +10,12 @@ export function getUsers(data = {}) { export function getUser(id) { if (id) { - return defAxios({ + return request({ url: `/user/${id}`, method: 'get', }) } - return defAxios({ + return request({ url: '/user', method: 'get', }) @@ -23,14 +23,14 @@ export function getUser(id) { export function saveUser(data = {}, id) { if (id) { - return defAxios({ + return request({ url: '/user', method: 'put', data, }) } - return defAxios({ + return request({ url: `/user/${id}`, method: 'put', data,