Skip to content

Commit

Permalink
refactor(articles/pagination): get current page number simply
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jan 25, 2024
1 parent 5d969cc commit fa8f5b4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/app/articles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ async function run(req: any): Promise<any> {
}

async function handler(req: any) {
let page = 1;
if (req.searchParams['p'] !== undefined) {
page = req.searchParams['p'];
}
const currentPage = req.searchParams['p'] ? req.searchParams['p'] : 1;
const ctx = requestContextFrom(headers());
const response: Response = await fetchFromApi(API_URL, ctx, {
interceptIfContainsIgnorePaths: false,
queryParams: null,
pagenation: {
page: page,
page: currentPage,
limit: 10
}
});
Expand All @@ -49,7 +46,7 @@ async function handler(req: any) {
return {
props: {
count: articlesResponseWithCount.count,
currentPage: page,
currentPage: currentPage,
articles: articles
}
}
Expand Down

0 comments on commit fa8f5b4

Please sign in to comment.