Skip to content

Commit

Permalink
fix: api호출 타입 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JjungminLee committed Mar 6, 2024
1 parent 6e03bba commit 16699db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/Logger.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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();
}
Expand Down
8 changes: 6 additions & 2 deletions src/SetLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/apis/postLog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LogRequestList, LogResponse } from '../types/LogType';
import { customedAxios } from './customedAxios';

export const postLog = async (data: LogRequestList[]): Promise<LogResponse> => {
export const postLog = async (data: LogRequestList): Promise<LogResponse> => {
const res = await customedAxios.put('/log/list', data);
return res.data;
};

0 comments on commit 16699db

Please sign in to comment.