I have a flow
it has one local variable audits , and it is a output
this flow is used in On init flow , using call service.
output mapping
but I am getting this error.
I have a flow
it has one local variable audits , and it is a output
this flow is used in On init flow , using call service.
output mapping
but I am getting this error.
Hi @JeevanKumar ,
Are you still getting this issue ??
Yes.
here I am trying to fetch data from api at the initialisation of page ,
the api call flow receives pagination input like skip and limit to pass to the api and it returns a list and totalCount ,
example api response
{
items: []
totalAudits : 39
}
my goal is to do pagination. If you have any other way to do this, please share step by step method.
For backend pagination you will definitely need the skip and limit from the frontend not on initilization only.
When clicking the previous and next icon on the pagination are you sending the limit and skip aswell ??
The error of undefined is not an object (evaluating ‘bh.local.audits’) are you still getting that ??
yes I am getting that error only when I set audits as output from the fetching flow.
I did pagination by calling fetching flow from (page) pick a flow of paginator
but its only works for nextPage button , previousPage is also updating skip + 10.
so
can you share right way to do pagination in frontend and backend.
Can you delete the call service, add it again, call the fetch Audits, map your output then see if you still getting the error.
From the frontend you need to only send the * page (current page number), limit (number of items per page) then on the backend you will calculate skip = (page - 1) * limit.
Suppose:
limit = 10When you click:
| Action | Page Sent to Backend | Backend skip calculation |
|---|---|---|
| Initial | 1 | (1 - 1) * 10 = 0 |
| Next | 2 | (2 - 1) * 10 = 10 |
| Next | 3 | (3 - 1) * 10 = 20 |
| Previous | 2 | (2 - 1) * 10 = 10 |
Backend code:
const page = parseInt(req.query.page) || 1;
const limit = parseInt(req.query.limit) || 10;
const skip = (page - 1) * limit;
Then you will set those to options on the mongoDB node prorpeties.
For better reference, I have dropped the link that will take you to MongoDB node and it will explain all the properties including the options where you can pass limit, page and skip to it.