Question: I am using `app.useStaticAssets(ui);` in NestJS app, to server my SPA. The application is running on a browser in kiosk mode. 

New kiosk hardware have 2 screens, front, back. It would be easiest if we could create another SPA and serve it on the same NestJS app.

I've looked at the NestJS docs, tried to inspect the source code and searched for related issues, have founds only hints, using res.sendFile (not sure about the assets) or using express under NestJS.

Is there a way to do this in straight NestJS?

Answer: 
What is happening here is that you are overriding the key that you store the product. If you do `localStorage.setItem('id', something)` and after `localStorage.setItem('id', otherThing)`. When you do `localStorage.getItem('id')` you will get `otherThing` because it overrided when you set the item to `something`.

In `localStorage`, you can only have unique keys. Can't have more than one value for the same key.

What you should do to save more than one product is save products as an array.

```
function addProductToCart() {
    let productsString = localStorage.getItem('products')
    let products = []
    if(productsString){
        products = JSON.parse(productsString)
    } 
    products.concat([location.state])
    localStorage.setItem('products', JSON.stringify(products)) // set products as an array
}

```

And when getting the product, you get the full array with all products.

```
const showProduct = () => {
    localStorage.getItem('products'); // gets an array of the products
} 

```

And if you want to get the last product, you should do

```
const getLastProduct = () => {
    let productString = localStorage.getItem('products')
    let products = JSON.parse(productString)
    return products[products.length - 1]
}

```

You should notice that you should save the array using `JSON.stringify` and get it using `JSON.parse`.
```
const addToCart = (data) => {
    var dataCart = JSON.parse(localStorage.getItem('cart'))
    var product = data
    product['amount'] = 1

    if (dataCart.length === 0 || !dataCart.find((p) => p.name === product.name)) {
      dataCart.push(product)
      localStorage.setItem('cart', JSON.stringify(dataCart))
    } else if (dataCart.find((p) => p.name === product.name)) {
      product['amount'] += dataCart.find((p) => p.name === product.name).amount
      dataCart.splice(
        dataCart.findIndex((p) => p.name === product.name),
        1,
        product
      )
      localStorage.setItem('cart', JSON.stringify(dataCart))
    }
  }

```