Ljj Posted November 18, 2019 Share Posted November 18, 2019 `addtocart = () => { console.log("adding to cart"); // const addtocarturl = "BFFRCL879WV8RDF35DY5MLVEMG19IKTJ@ec2-3-16-44-207.us-east-2.compute.amazonaws.com/api/carts?schema=blank"; // this.navigate.addtocarturl // http://ec2-3-16-44-207.us-east-2.compute.amazonaws.com/api/carts?ws_key=BFFRCL879WV8RDF35DY5MLVEMG19IKTJ&schema=blank fetch('http://ec2-3-16-44-207.us-east-2.compute.amazonaws.com/api/carts?ws_key=BFFRCL879WV8RDF35DY5MLVEMG19IKTJ&schema=blank', { method: 'POST', headers: { "async": true, "crossDomain": true, 'Accept': "*/*", 'Content-Type': 'application/xml', // <-- Specifying the Content-Type "Authorization": "Basic QkZGUkNMODc5V1Y4UkRGMzVEWTVNTFZFTUcxOUlLVEo6", "Host": "ec2-3-16-44-207.us-east-2.compute.amazonaws.com", "Connection": "keep-alive", "cache-control": "no-cache", }, body: <prestashop> <cart> <id_address_delivery>10</id_address_delivery> <id_address_invoice>10</id_address_invoice> <id_currency >1</id_currency> <id_customer>19</id_customer> <id_lang >1</id_lang> <delivery_option/> <secure_key/> <allow_seperated_package>0</allow_seperated_package> <date_add>2015-06-23 14:45:08</date_add> <date_upd>2015-06-23 14:45:08</date_upd> <associations><cart_rows> <cart_row> <id_product>50</id_product> <id_product_attribute >0</id_product_attribute> <id_address_delivery >10</id_address_delivery> <quantity>7</quantity> </cart_row> </cart_rows> </associations> </cart> </prestashop> }) .then((responseData) => { console.log(responseData) }) .catch((err) => { console.log(err); }); }` This post method am using to add the product in the cart. its throwing error : Invariant Violation: is not usable as a native method argument Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now