TypebotT
Typebot2y ago
gk

Storing and displaying arrays returned by an API

Hi, guys.

Suppose I have the following JSON as an API return and would like to store and display (in one or more text bubbles) each sale with their respective products's prices. What's the best way to do this?

{
  "sales": [
    {
      "id": 1,
      "name": "sale 01",
      "products": [
        {
          "id": 1,
          "name": "product 01",
          "price": 2.32
        },
        {
          "id": 2,
          "name": "product 02",
          "price": 5.99
        }
      ]
    },
    {
      "id": 2,
      "name": "sale 02",
      "products": []
    },
    {
      "id": 3,
      "name": "sale 03",
      "products": [
        {
          "id": 1,
          "name": "product 01",
          "price": 2.25
        }
      ]
    }
  ]
}
Was this page helpful?