完善获取文章列表

This commit is contained in:
tangly1024
2022-05-09 13:52:44 +08:00
parent d200420c31
commit adac140892
4 changed files with 41 additions and 25 deletions

View File

@@ -13,7 +13,11 @@ export async function getPostBlocks(id, from, slice) {
console.warn('[请求API]:', `from:${from}`, `id:${id}`)
pageBlock = await getPageWithRetry(id, from)
console.warn('[请求完成]: 结果', `${pageBlock ? '成功' : '失败'}`, `from:${from}`, `id:${id}`)
if (pageBlock) {
console.info('[请求成功]:', `from:${from}`, `id:${id}`)
} else {
console.error('[请求失败]:', `from:${from}`, `id:${id}`)
}
if (pageBlock) {
await setDataToCache(cacheKey, pageBlock)
@@ -29,7 +33,7 @@ export async function getPostBlocks(id, from, slice) {
*/
async function getPageWithRetry(id, from, retryAttempts = 3) {
if (retryAttempts && retryAttempts > 0) {
console.log('[发起请求]', `from:${from}`, `id:${id}`, `剩余重试次数:${retryAttempts}`)
console.log('[发起请求]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '')
try {
const authToken = BLOG.NOTION_ACCESS_TOKEN || null
const api = new NotionAPI({ authToken })