diff --git a/src/Logger.ts b/src/Logger.ts index eaceaf7..ed3c81b 100644 --- a/src/Logger.ts +++ b/src/Logger.ts @@ -1,5 +1,5 @@ import { SetLocalStorage, SetLocalStorageClear } from './SetLocalStorage'; -import { LogPayloadParams, LogType } from './types/LogType'; +import { LogPayloadParams, LogRequestList, LogType } from './types/LogType'; import CryptoJS from 'crypto-js'; import { postLog } from './apis/postLog'; @@ -82,7 +82,10 @@ window.addEventListener('unload', async (event) => { event.preventDefault(); const logList: LogType[] = JSON.parse(localStorage.getItem('yls-web') as string) || []; - const res = await postLog([{ logRequestList: logList }]); + const req: LogRequestList = { + logRequestList: logList, + }; + const res = await postLog(req); if (res.success) { SetLocalStorageClear(); } diff --git a/src/SetLocalStorage.ts b/src/SetLocalStorage.ts index 477acb7..a8a01a1 100644 --- a/src/SetLocalStorage.ts +++ b/src/SetLocalStorage.ts @@ -1,5 +1,5 @@ import { postLog } from './apis/postLog'; -import { LogType } from './types/LogType'; +import { LogRequestList, LogType } from './types/LogType'; export const SetLocalStorageClear = () => { const list: any[] = []; @@ -17,7 +17,11 @@ export const SetLocalStorage = async (logger: LogType) => { const updateList = [...remainList, logger]; localStorage.setItem('yls-web', JSON.stringify(updateList)); } else { - const res = await postLog(remainList); + const req: LogRequestList = { + logRequestList: remainList, + }; + const res = await postLog(req); + if (res.success) { SetLocalStorageClear(); } diff --git a/src/apis/postLog.ts b/src/apis/postLog.ts index 1a097ce..983c899 100644 --- a/src/apis/postLog.ts +++ b/src/apis/postLog.ts @@ -1,7 +1,7 @@ import { LogRequestList, LogResponse } from '../types/LogType'; import { customedAxios } from './customedAxios'; -export const postLog = async (data: LogRequestList[]): Promise => { +export const postLog = async (data: LogRequestList): Promise => { const res = await customedAxios.put('/log/list', data); return res.data; };