Jump to content

Endpoint for react application


PrestaApi

Recommended Posts

I'm interested in the ability to get information through the endpoints, is it possible to get information, for example, about the product in more detail, characteristics, reviews, options with prices, why the official api look, not full? or do you have to submit your own endpoint for each page?api look, not full? or do you have to submit your own endpoint for each page?

Link to comment
Share on other sites

  • 10 months later...

Hello Ventura,

Thanks for your answer

I am using axios here is my code below. 

i have a CORS issue that I am trying to figure out (i'm working on my localhost right now) but is my logic here correct ?

const handleSubmit = async () => {

    const xmlData =

    `<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">

    <order>

    <id_address_delivery><${customerAddress.id}></id_address_delivery>

    <id_address_invoice><${customerAddress.id}></id_address_invoice>

    <id_currency><${cartSummary.id_currency}></id_currency>

    <id_lang><${cartSummary.id_lang}></id_lang>

    <id_customer><${selectedCustomer.id}></id_customer>

    <id_carrier><${cartSummary.id_carrier}></id_carrier>

    <current_state><${cartSummary.current_state}></current_state>

    <id_shop_group><${cartSummary.id_group_shop}></id_shop_group>

    <id_shop><${cartSummary.id_shop}></id_shop>

    <total_discounts><${totalSavings}></total_discounts>

    <total_paid><${grandTotal}></total_paid>

    <total_paid_tax_incl><${grandTotal}></total_paid_tax_incl>

    <total_products><${totalQuantity}></total_products>

    <associations>

    <order_rows>

    ${cart.map((item, index) => {

      return `<order_row>

      <id><${index +1 }></id>

      <product_id><${item.productId}></product_id>

      <product_quantity><${item.quantity}></product_quantity>

      <product_name><${item.productName}></product_name>

      <product_price><${item.total_paid}></product_price>

      <unit_price_tax_incl><${item.discountedTotal}></unit_price_tax_incl>

      </order_row>`;

    }).join('')}

    </order_rows>

    </associations>

    </order>

    </prestashop>`;

    console.log(xmlData);



    try {

      const config = {

        headers: {

          'Content-Type': 'text/xml',

        }

      };


     const response = await axios.post('https://dev.mydomainname.com/api/orders?ws_key=${mykey}', xmlData, config);

     console.log('Réponse de l\'API:', response.data);

   } catch (error) {

     console.error('Erreur:', error);

   }

 };

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...