Pushing json to index, but the output is an error :(

Hi there,
I am using Redux to manage the state of my application and as such and I have my action creators dispatching an object to my store that was fetched from an airtable database.

Now I am implementing algolia and as such I would like to set up my index in algolia. That would mean that I will need to send my data, in a slightly different way, to algolia to build my index. However, when I do / use index.addObjects() I will get the following error message -> TypeError: index.addObjects is not a function

I am not entirely sure why this is happening, any thoughts?

Thank you for the help.
Cheers,
Tiago

Hello there!

The message you’re getting indicates a typical JavaScript issue which happens when you’re trying to call a method on an undefined object. Can you make sure that index is properly instantiated, and returns an object which contain the addObjects method?

Here’s a step by step guide on how to instantiate the client and index with JavaScript: https://www.algolia.com/doc/api-client/getting-started/instantiate-client-index/#init-index

Please share your code (without your private API key) if the issue persists.

Happy coding!

Thank you very much @sarah.dayan. Still not sure why this is not working, bellow you can see my code:

export const getAllStartups = () => {
    return dispatch => {
        dispatch(getAllStartupsStart());
        let allStartups = [];
        base('collab DB').select({ view: view })
        .eachPage(
            (records, fetchNextPage) => {
                //all this is to solve for a problem when I have more than 100 items
                allStartups = [
                    records, 
                    ...allStartups]
                    .reduce((acc , cv) => {
                        return acc.concat(cv)
                    }) 
                fetchNextPage();
                dispatch(getAllStartupsSuccess(allStartups))
                
                let toAlgolia = [];
                toAlgolia = allStartups.map(record => {
                    let obj = {};
                    obj["objectID"]=record.id
                    obj["data"]=record.fields
                    return obj
                }); 
            
                console.log(toAlgolia);
                index.addObjects(data)

I suspect that my problem could my fetch to airtable as it returns 2 array of objects in different instances?
This is my console.log()


Dos this make any sense?