How to use REST API to delete up to ten records at a time using Node.js library axios?

How do I use the REST API to delete ten records at a time using axios?

I can successfully delete one record at a time, but due to the API design, I am having a problem constructing the URL to delete ten at a time.


Here is what works with one record at a time:

I am using a library in Node.js called axios to do HTTP method calls, and here is the call that works:

await axios.delete(url, {params: params, headers: headers})
	.then(async function(response) {
        console.log('DELETED:',
            response.status,
            response.statusText);
});

I define params this way (I have a method call that returns the params to send to axios)

params = await getParams(rec);  // rec is the Airtable record identifier like: `rec
async function getDelParams(rec) {
    const params = {
        'records[]': rec		// rec is like: rec5GWL8xCpofFKFC
    };
    return params
}

In this key/value pair, I can only have one entry of : records[] , no more, I need ten.

The REST API requires multiple records like:

records[]=rec5GWL8xCpofFKFC&records[]=rec5GWL8xCpofFLSD&records[]=rec5GWL8xCpofXMAS

and so on, up to ten max.

but axios accepts params as a list of key/value pairs, and there can be only one key: records[] in the list.

I need key/value pairs because I have other keys/values that I am sending, and this makes it convenient.

How can I use axios/key value pairs to make this work so that it sends 10 at a time, instead of one at a time?


Follow up:

What could be done here (or what is typically done here) to design a better API to accept a list of values with one key?

I’m not familiar with the axios library but I was wondering if it’s a simple matter of including the ten record id’s as items in the records[] array.

records['rec5GWL8xCpofFKFC','rec5GWL8xCpofFLSD','rec5GWL8xCpofXMAS', ...]

The javascript API seems to intimate this exact approach.