The generated API clients are a work in progress, you can also find our stable clients on the Algolia documentation.

Skip to main content

Wait for a task to finish

The waitForTask method is only available in the search client context.

Some operations related to the Algolia index are not always instantaneous. Doing such operations with our API clients will provide a taskID in the response body, so you can later know what is the status of your operation.

We provide a waitForTask helper method for you to easily wait for a specific task status.

import { searchClient } from '@algolia/client-search';

const client = searchClient('YOUR_APP_ID', 'YOUR_API_KEY');

const response = await client.deleteObject({
indexName: '<YOUR_INDEX_NAME>',
objectID: 'uniqueID',
});

// use typed response
console.log(response);

await client.waitForTask({ indexName: '<YOUR_INDEX_NAME>', taskID: response.taskID });