# insert

Insert function is used to insert an object, an array, or data to a node in the reducer tree.

```javascript
dispatch(insert('DESTINATION', 'OBJECT-NAME', PAYLOAD )); 
```

There are 3 parameters: \
\&#xNAN;*Destination***:** which could be a [*destination path*](https://docs.no-reducer.com/no-reducer/no-reducer-actions/destination-path) or the name of the object you want to insert to. \
\&#xNAN;*Object name*: the name of the object \
\&#xNAN;*Payload:* the value of the object; it could be an object, array, or data.

**Example 1:** \
We want to add an object `{ food: ‘crawfish’ }` to the User object.

```javascript
dispatch(insert('User', 'food', 'crawfish'));
```

<figure><img src="https://2096029297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa8hQdsN7Pv00B1Pt9tuc%2Fuploads%2FElDMMtTY4PMgatCHRn9o%2F68747470733a2f2f766e73656174746c652e636f6d2f64796e616d6963526564756365722f496e73657274416e4f626a656374322e706e67.png?alt=media&#x26;token=85b441f8-4a2b-4fa2-b575-ae66d1b357f3" alt=""><figcaption></figcaption></figure>

**Example 2:**\
Insert an array `meal: ["crawfish", "corn", "hotdog", "shrimp"]` to the User

```javascript
dispatch(insert('User', 'meal', ["crawfish", "corn", "hotdog", "shrimp"]));
```

<figure><img src="https://2096029297-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa8hQdsN7Pv00B1Pt9tuc%2Fuploads%2Ff3hwn026GcnSd4FWSXrs%2F68747470733a2f2f766e73656174746c652e636f6d2f64796e616d6963526564756365722f496e736572744d65616c322e706e67.png?alt=media&#x26;token=fb96e06d-1e01-4375-97ac-1a6cb45385b2" alt=""><figcaption></figcaption></figure>
