how can we get cart id in response

Hashir
New Member
3 0 0

hi, how can we get cart id in response of the request of cart.js,

i'm sending request to shopify using their API cart.js and here is the request 

jQuery.getJSON('/cart.json')
    .then(response => {
        console.log(response);
    })
    .catch((error) => {
        console.error('Error:', error);
    });

and here is the response 

{token: "c291e45ef9cf014cccd65fc23ebfa16a", note: null, attributes: {…}, original_total_price: 1000, total_price: 1000, …}
attributes: {}
cart_level_discount_applications: []
currency: "PKR"
item_count: 1
items: [{…}]
items_subtotal_price: 1000
note: null
original_total_price: 1000
requires_shipping: true
token: "c291e45ef9cf014cccd65fc23ebfa16a"
total_discount: 0
total_price: 1000
total_weight: 500
__proto__: Object

but it doesn't return cart id in this response

 

so can anyone please help me how to get cart id in response here ??
Thanks in advance

0 Likes