jeudi 2 mai 2019

Get ecommerce inventory levels through on-site JS code that checks if the item is available

I noticed that many ecommerce websites have some JavaScript that checks with an API the existance of a product. I wonder if one can access that API or server and get the inventory levels of any ecommerce site, since all of them should have some kind of script checking the buyer does not exceed current inventory levels of a product.

I searched many ecommerce sites in my country (Chile), and all of them do check the availability of items through JavaScript. For example, Falabella.com website has a "getInventoryStock" function inside "productDetailApp.js", but I have not been able to understand the way it works or how can I use this function.

In some websites I have been able to access the API checking the Network inspector in Chrome. But I noticed that maybe this kind of requests that run through JavaScript do not make a front-end request to the API, and run through the server instead.

I include the function that Falabella.com uses to get inventory levels.

function(e, t, n) {
    "use strict";
    (function(e) {
        function r(t) {
            if (!t.success) {
                var n = {
                    title: "Error",
                    msg: t.errors[0].message
                };
                return o.a.publish("Modal:show-error", n),
                e.reject(t)
            }
            return e.resolve(t)
        }
        var a = n(19)
          , i = n(4)
          , o = n.n(i)
          , s = {}
          , l = function(e, t) {
            return s[e] ? s[e] : (s[e] = t(),
            s[e])
        }
          , p = {
            path: "/rest/model/falabella/rest/browse/BrowseActor/get-facility-RT-stock"
        }
          , b = {
            getInventoryStock: function(e, t) {
                var n = e.getFacilityRTStock
                  , i = n ? n.path : p.path;
                return a.a.get(i, t).then(r)




Aucun commentaire:

Enregistrer un commentaire