# upsertRequest was null or undefined when calling upsert

**URL:** <https://community.pinecone.io/t/upsertrequest-was-null-or-undefined-when-calling-upsert/1530>\
**Category:** Support\
**Created:** [April 25, 2023, 7:18pm UTC](https://community.pinecone.io/t/upsertrequest-was-null-or-undefined-when-calling-upsert/1530 "2023-04-25T19:18:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![assaf](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/assaf/32/710_2.png) [@assaf](https://community.pinecone.io/u/assaf)\
**Post date:** [April 25, 2023, 7:18pm UTC](https://community.pinecone.io/t/upsertrequest-was-null-or-undefined-when-calling-upsert/1530/1 "2023-04-25T19:18:39Z")

</div>

Trying to do an upsert using the node client and getting an error:

````auto
}```

Code is as follows:

async function saveEmbeddings(documents) {
  const vectors = documents.map((doc) => {
    return {
      id: doc.metadata.source.replace(/-/g, '_'),
      values: doc.embedding,
      metadata: { topic: doc.metadata.source, source: folder }
    }
  });

/* [ {
    id: '40-character-string',
    values: [...1536 values],
    metadata: {
      topic: '40-character-string',
      source: 'Book'
    }
  }]
*/

  const results = await pineconeIndex.upsert({ vectors });
//error here
}

Seems odd because upsertRequest certainly isn't null. Any thoughts? Everything else seems to work.
````

---

<div class="post-metadata">

**Author:** ![Jasper](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/jasper/32/4514_2.png) [@Jasper](https://community.pinecone.io/u/Jasper)\
**Post date:** [April 26, 2023, 9:09am UTC](https://community.pinecone.io/t/upsertrequest-was-null-or-undefined-when-calling-upsert/1530/2 "2023-04-26T09:09:28Z")

</div>

Hi,

your example looks good to me. The only thing I see that might be a problematic and cause you your error is from the example here: [https://docs.pinecone.io/docs/node-client#indexupsert](https://docs.pinecone.io/docs/node-client#indexupsert)

Try modifying your code like this:

```js
const results = await pineconeIndex.upsert({
      upsertRequest: { //added line
         vectors: vectors
     } // added line
});

```

Let me know if this worked for you

---

<div class="post-metadata">

**Author:** ![assaf](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/assaf/32/710_2.png) [@assaf](https://community.pinecone.io/u/assaf)\
**Post date:** [April 26, 2023, 6:30pm UTC](https://community.pinecone.io/t/upsertrequest-was-null-or-undefined-when-calling-upsert/1530/4 "2023-04-26T18:30:14Z")

</div>

Ah! I see - the upsert function takes an object with a property `upsertRequest`. Can’t believe I missed that. Thanks!
