Should have saved my progress earlier. Trying to redo things without using localStorage initially. Shared data...

This commit is contained in:
Scott Idem
2024-03-27 11:36:06 -04:00
parent a8a2131361
commit 3082c07e3e
5 changed files with 109 additions and 33 deletions

View File

@@ -92,12 +92,10 @@ export let get_object = async function get_object({api_cfg, endpoint='', headers
/* other custom settings */
});
axios_api.defaults.headers = api_cfg['headers'];
console.log(axios_api.defaults.headers);
console.log('axios_api.defaults.headers:', axios_api.defaults.headers);
console.log('Additional headers:', headers);
// console.log(headers);
console.log('Clean the headers. No _underscores_!')
// console.log('Clean the headers. No _underscores_!')
let headers_cleaned = {};
for (const prop in headers) {
// No underscores allowed in the header parameters!
@@ -115,7 +113,7 @@ export let get_object = async function get_object({api_cfg, endpoint='', headers
}
}
headers = headers_cleaned;
console.log('Cleaned additional headers:', headers);
console.log('All headers cleaned:', headers);
console.log('URL params:');
for (const prop in params) {
@@ -152,7 +150,7 @@ export let get_object = async function get_object({api_cfg, endpoint='', headers
let percent_completed = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
console.log('GET Data Timestamp:', progressEvent.timeStamp, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
// console.log('GET Data Timestamp:', progressEvent.timeStamp, 'Total:', progressEvent.total, 'Loaded:', progressEvent.loaded, 'Percent Completed', percent_completed);
temp_get_object_percent_completed = percent_completed;
}
@@ -615,7 +613,17 @@ export let get_ae_obj_id_crud = async function get_ae_obj_id_crud({
if (no_account_id) {
headers['x-no-account-id'] = 'Nothing to See Here';
delete headers['x-account-id'];
delete api_cfg['headers']['x-account-id'];
// headers['x-account-id'] = null;
// headers['x-account-id'] = '_XY7DXtc9Mxx';
// params['x_no_account_id_token'] = 'Nothing to See Here';
// Remove the x-account-id header
// if (headers['x-account-id']) {
// delete headers['x-account-id'];
// }
// headers['x-account-id'] = null;
// headers['x-no-account-id-token'] = 'Nothing to See Here'; // get_object() will fix the underscores to dashes
}
@@ -1328,13 +1336,13 @@ export let get_data_store_obj_w_code = async function get_data_store_obj_w_code(
if (data_store_obj_get_promise === false) {
console.log('Data Store - RUN AGAIN WITH BACKUP');
let original_api_base_url = api_cfg['base_url'];
// let original_api_base_url = api_cfg['base_url'];
let temp_api = api_cfg;
temp_api['base_url'] = temp_api['base_url_bak']
// let temp_api = api_cfg;
// temp_api['base_url'] = temp_api['base_url_bak']
data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, timeout: 6000, log_lvl: log_lvl});
temp_api['base_url'] = original_api_base_url;
// data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, timeout: 6000, log_lvl: log_lvl});
// temp_api['base_url'] = original_api_base_url;
}
let data_store_obj = data_store_obj_get_promise;