Algolia addObject not pushing data to Index

Hello, I am a recently new developer using Algolia for the first time.
I am having trouble pushing data to my Index using Algolia’s addObject. Can anyone tell me what I’m doing wrong.

51%20PM

Hi mjubilee,

What errors are you getting? For the API Key, are you using the search only API key or the write or admin key?

Best,
Oliver

Idk which API key I am using where can I find out my key in Algolia web app.

Here are some docs on the addObject for reference: https://www.algolia.com/doc/api-reference/api-methods/add-objects/

API key can be found in the Algolia dashboard (left side has tab API key).

Best,
Oliver

Okay I only have a Search API key. How do I generate Add API key. I also went through the docs and it didn’t make sense for me.

Hi @mjubilee,

Continuing with @oliver.han’s advice here are three things to look into:

  • API Key with write capabilities - In your Algolia Dashboard > navigate to “API Keys” > then either use the “Admin API Key” or generate one with ability to add objects:

  • object structure - Inspect your this.state.items and confirm it is actually valid JSON format like:
{
  firstname: 'Jimmie',
  lastname: 'Barninger'
}, {
  firstname: 'Warren',
  lastname: 'Speach'
}
  • typos - I noticed you used addObject without the “s”, when the method is addObjects plural with “s”. Please see if this also resolves your issue.

If you continue to run into issues, can you console.log your error and share it with us in a follow-up message?

Hope this helps,