Data returned from JavaScript endpoint is shown as a placeholder in a Flow JSON

I’m returning data from an endpoint to a WhatsApp FLow JSON in this format and when I log it, the logs say that the data is being returned successfully:

const response = {
  screen: "CART",
  data: {
    totalAmount: totalAmount
  }
};

And then I try to use that returned value in the CART screen of the WhatsApp Flow JSON by using the ${data.totalAmount} format like this:

"id": "CART",
  "title": "Cart",
  "terminal": true,
  
  "layout": {
    "type": "SingleColumnLayout",
    "children": [
      {
        "type": "TextBody",
        "text": "Total Amount: ${data.totalAmount}",
        "visible": true
      }

But it just returns the placeholder and not the values that was received from the endpoint.
I have tried the to add this data property to the screen, but it still returned the placeholder and not the values that was returned by the endpoint:

{
      "id": "CART",
      "title": "Cart",
      "terminal": true,
      "data": {
        "amount": {
          "type": "object",
          "__example__": {
            "value": "100.00"
          },
          "value": "${data.totalAmount}"
        }
      },
      "layout": {
        "type": "SingleColumnLayout",
        "children": [
          {
            "type": "TextBody",
            "text": "Total Amount: ${data.value}",
            "visible": true
          },

The same result is returned when I try to use ${data.amount.value} as it just returns the placeholder.