//---------------------------------
// Get settings for main page
function getSettings() {

    // Read JSON from a file
    fetch("setup.json")
    .then(function(resp)
        {
            return resp.json();
        }        
    )
    .then(
        function(jsonData) {
            let settings = jsonData.setup;

            gblSetUp = settings;
            //console.log(gblSetUp);       
            
            showProducts();

            // Calculate the basket total
            updatebaskettotal();
        }
    )
    .catch(err=>{
        errorMessage(err.message);
    });

}

//--------------------------------------------
// Display any error message to the console
function errorMessage(err){
        console.error(err);
}

//---------------------------------
// Get settings for cart
// Could use getSettings() but that requires showProducts() and updatebaskettotal
// while this just needs showCart()
function getSettingsForCart() {

    // Read JSON from a file
    fetch("setup.json")
    .then(function(resp)
        {
            return resp.json();
        }        
    )
    .then(
        function(jsonData) {
            let settings = jsonData.setup;

            gblSetUp = settings;

            showCart();
        }
    )
    .catch(err=>{
        errorMessage(err.message);
    });

}
