make fetchlog limit to 20
This commit is contained in:
@@ -624,28 +624,32 @@ export async function globalFetch(url: string, arg: GlobalFetchArgs = {}): Promi
|
|||||||
|
|
||||||
// Decoupled globalFetch built-in function
|
// Decoupled globalFetch built-in function
|
||||||
function addFetchLogInGlobalFetch(response:any, success:boolean, url:string, arg:GlobalFetchArgs){
|
function addFetchLogInGlobalFetch(response:any, success:boolean, url:string, arg:GlobalFetchArgs){
|
||||||
try{
|
try{
|
||||||
fetchLog.unshift({
|
fetchLog.unshift({
|
||||||
body: JSON.stringify(arg.body, null, 2),
|
body: JSON.stringify(arg.body, null, 2),
|
||||||
header: JSON.stringify(arg.headers ?? {}, null, 2),
|
header: JSON.stringify(arg.headers ?? {}, null, 2),
|
||||||
response: JSON.stringify(response, null, 2),
|
response: JSON.stringify(response, null, 2),
|
||||||
success: success,
|
success: success,
|
||||||
date: (new Date()).toLocaleTimeString(),
|
date: (new Date()).toLocaleTimeString(),
|
||||||
url: url,
|
url: url,
|
||||||
chatId: arg.chatId
|
chatId: arg.chatId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch{
|
catch{
|
||||||
fetchLog.unshift({
|
fetchLog.unshift({
|
||||||
body: JSON.stringify(arg.body, null, 2),
|
body: JSON.stringify(arg.body, null, 2),
|
||||||
header: JSON.stringify(arg.headers ?? {}, null, 2),
|
header: JSON.stringify(arg.headers ?? {}, null, 2),
|
||||||
response: `${response}`,
|
response: `${response}`,
|
||||||
success: success,
|
success: success,
|
||||||
date: (new Date()).toLocaleTimeString(),
|
date: (new Date()).toLocaleTimeString(),
|
||||||
url: url,
|
url: url,
|
||||||
chatId: arg.chatId
|
chatId: arg.chatId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fetchLog.length > 20){
|
||||||
|
fetchLog.pop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoupled globalFetch built-in function
|
// Decoupled globalFetch built-in function
|
||||||
|
|||||||
Reference in New Issue
Block a user