Documentation
You can copy paste the code in your browser console to quickly test Store API.
Cart
Get All Carts
fetch('https://api.storerestapi.com/carts')
.then(response => response.json())
.then(json => console.log(json))
Get Single Cart
fetch('https://api.storerestapi.com/carts/6572b9c1f610af2847fcba15')
.then(response => response.json())
.then(json => console.log(json))
Add New Cart
fetch('https://api.storerestapi.com/carts',
{
method: 'POST',
body: JSON.stringify({
"userId": "612e48bf345dcc333ac6cb28",
"products": [
{
"productId": "61ab43350f34753bcedfa7aa",
"quantity": 5
},
{
"productId": "61ab434b0f34753bcedfa7ae",
"quantity": 7
}
]
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then(response => response.json())
.then(json => console.log(json))
Update Cart
fetch('https://api.storerestapi.com/carts/6572b9c1f610af2847fcba15',
{
method: 'PUT',
body: JSON.stringify({
"products": [
{ "productId": "61ab42d00f34753bcedfa79e", "quantity": 5 },
{ "productId": "61ab42e90f34753bcedfa7a2", "quantity": 3 }
]
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then(response => response.json())
.then(json => console.log(json))
Delete Cart
fetch('https://api.storerestapi.com/carts/6572b9c1f610af2847fcba15',
{
method: 'DELETE',
})
.then(response => response.json())
.then(json => console.log(json))