General clean up. Improved event search and listing for IDAA.

This commit is contained in:
Scott Idem
2024-10-01 16:08:31 -04:00
parent cca43b957a
commit 47e9f9f5a1
16 changed files with 256 additions and 139 deletions

View File

@@ -0,0 +1,63 @@
import axios from 'axios';
// Updated 2024-05-23
export let delete_object = async function delete_object(
{
api_cfg=null,
endpoint='',
params={},
data={},
return_meta=false,
log_lvl=0
}: {
api_cfg: any,
endpoint: string,
params?: any,
data?: any,
return_meta?: boolean,
log_lvl?: number
}
) {
console.log('*** delete_object() ***');
if (log_lvl) {
// console.log(api_cfg);
console.log(endpoint);
console.log(params);
if (log_lvl > 1) {
console.log('Data:', data);
console.log(typeof data);
}
// console.log(return_meta);
// console.log(as_list);
}
// https://stackoverflow.com/questions/51069552/axios-delete-request-with-body-and-headers
let axios_api = axios.create({
baseURL: api_cfg['base_url'],
// timeout: 2000,
/* other custom settings */
});
axios_api.defaults.headers = api_cfg['headers'];
//OLD: axios_api.delete(endpoint, { 'data': data })
let response_data = await axios_api.delete(endpoint, { params: params, 'data': data })
.then(function (response) {
console.log(response.data);
return response.data;
})
.catch(function (error) {
if (error.response && error.response.status === 404) {
return null; // Returning null since there were no results
}
console.log(error);
return false; // Returning false since something may have gone wrong. Also more in line with what the API returns.
// return error;
});
if (log_lvl > 1) {
console.log(response_data);
}
return response_data;
}