NolWag
NolWag

Reputation: 21

How to access property inside of this object?

Trying to access "responseJSON.original_total_price"

This is my code -

  const CartObject = theme.cart.getCart();
  console.log(CartObject.responseJSON.original_total_price)

Console View

Upvotes: 0

Views: 58

Answers (2)

NolWag
NolWag

Reputation: 21

Making it an async function fixed it.

  const CartObject = await theme.cart.getCart();
  CartObject.total_price

Upvotes: 2

Vulwsztyn
Vulwsztyn

Reputation: 2261

you need to use JSON.parse function on response e.g.

const responseParsed = JSON.parse(responseJSON.responseText)

Upvotes: 0

Related Questions