Closed kevinrblake closed 5 years ago
Hi Kevin. So, could you send me the complete JSON of that request?
Looking at the Json ({"cart_id":"1xh7q2ze08jxdorebr"},"product_id":2,"attributes":"XL, Orange"}), I discovered that the cart_id returned from the api come back, not as a simple string but as an object and I wasn't pulling it out of the object. It's working now.
Thanks for the prompt answer though =)
I used the api to generate a unique cart Id then tried to add a product to a cart using that id and I got
"Error: Invalid value { cart_id: '1xh7q2ze08jxcklvqr' }"
, however, that same cart_id works in Swagger.Should I simply generate my own unique identifier or is there something I'm doing wrong? Also, it generates a cart when I send '' as a cart_id.
Product object;
{ cart_id: this.bagId, product_id: product.product_id, attributes: attributeString }
bagId is the generated id and attributeString is a combination of size and color seperated by a comma
'L, White'
Service method:
static async addProductToCart(product) { try { const response = await axios.post('https:backendapi.turing.com/shoppingcart/add', product) return response.data } catch(error){ console.log(error) } }