Help

Re: Receive more than 100 records

5325 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Stefan_Welsh
5 - Automation Enthusiast
5 - Automation Enthusiast

I have written a little vue.js app. I need it to access more than 100 records in my table though. How do I do that?

Here is my code.var app = new Vue({
el: ‘#app’,
data: {
items: []
},
mounted: function(){
this.loadItems();
},
methods: {
loadItems: function(){

                    // Init variables
                    var self = this
                    var app_id = "XXXXXXXXXXXXXXXX";
                    var app_key = "XXXXXXXXXXXXXXX";
                    this.items = []

axios.get(
https://api.airtable.com/v0/"+app_id+"/Donor Honor Roll?view=Grid%20view”,
{
headers: { Authorization: "Bearer "+app_key }
}
).then(function(response){
self.items = response.data.records
}).catch(function(error){
console.log(error)
})
}
}
})

Any help is appreciated.

14 Replies 14
Andrew_Johnson1
8 - Airtable Astronomer
8 - Airtable Astronomer

The Airtable API uses the concept of pagination.
It returns at most 100 records in one call.

The response will contain an offset if there are more than 100 records. Include this offset in the next request’s parameters

openside
10 - Mercury
10 - Mercury

If you use the js library provided by airtable (https://github.com/airtable/airtable.js ) it handles paging for you.

Thanks, but I am not even sure where to start there. Not exactly a strong .js guy, but was able to follow a tutorial for vue.js to get info from my table. I see there is fetchNextPage(); but where would that go in my code now? I don’t want the user to have to click on anything to see the next record, I just want them all to be there.

@Stefan_Welsh openside is right but Airtable has really poor documentation for this so look at this file: https://github.com/Airtable/airtable.js/blob/master/test/test_files/index.html

Tiago_Sanchez
5 - Automation Enthusiast
5 - Automation Enthusiast

Anyone figure this out? I know that this topic is old, but I am still trying to figure it out.
Thus far I have this for the first 100 data points:

Screenshot 2019-07-23 at 10.50.07 PM.png

any ideas on how to proceed? I don’t want to use the fecthNextPage() option on airtable.js

@Tiago_Sanchez did you ever figure this out? I am trying to do this with axious and the rest url as well.

Dev_Local
6 - Interface Innovator
6 - Interface Innovator

This question is still open, without an answer:

I am not seeing that this question was answered (using Node.js and HTTP GET to paginate)

I have gone through every response, and nothing here is useful, that answers the question in those terms.

Looking at the article: “How to paginate records in Airtable when using the API” is not helpful. It is not directed at using HTTP GET and pagination.

Even if the answer were not specific to Node, but just GET, and params, would be sufficient.

I cannot map anything the article mentioned to the API examples given in the API documentation on how to paginate.

In addition the article is not a fully functional working example, it is missing pieces that would make it functional, and those pieces are essential in understanding a working example.


I have an axios GET call to fetch the first 100 records successfully (or up to 100 using the param: ?maxRecords=100)

There is nothing that I can see in the response that indicates an offset to use on the next call.

  1. Where do I get the offset? ( I need it for the last response, to specify how many to get? )
  2. How do I know when there are no more records, when doing repeated GET’s?

So the question is:

Is there a fully working example anywhere (axios / node), using GET to paginate, fetching all records from a table (100 at a time, until there are no more)?


A good example, using axios.get to loop, and process each batch of 100 when it comes back, would be extremely helpful.

Thank you,

here is a good starting point, the only thing missing is what the for loop would look like, how to exit.

function processRecords() {
    console.log('processRecords()');
    // do stuff
}

const processTable = async () => {
    const url = `https://api.airtable.com/v0/` + atApiBaseKey + `/` + atTableName;
    const headers = {
        'Authorization': "Bearer " + atApiKey,
        'Content-Type': "application/json"
    };

    try {
        let offset = 0;    // no initial offset
        let params = {
            maxRecords: 100,
            offset: offset
        };

        /**
         * how to loop here over await axios.get() ?
         *
         * what would a for loop look like here, incrementing offset by 100
         * each time?
         *
         * and how would the loop exit?
         *
         */

        await axios.get(url, {params: params, headers: headers})
            .then((response) => {
                processRecords(response.data.records);  // process 100 records

                //console.log(response.data);
                //console.log(response.status);
                //console.log(response.statusText);
                //console.log(response.headers);
                //console.log(response.config);
                console.log('')
            });
    } catch (error) {
        console.error(error)
    }
};