this code stringifys the data to be logged i need to use to fill my table:
// Define an async function to make the HTTP request
async function fetchData() {
try {
// Make an HTTP GET request to the API endpoint
const response3 = await axios.get('https://cybh7excdzyqofqbzgm2h6vwn40xpzmu.lambda-url.us-east-1.on.aws/');
// Log the response data
console.log('Data from HTTP endpoint:', response3.data);
// Store the data in workflow.data
workflow.teamStandings = response3.data;
// Stringify the data with replacer function
const stringifiedData = JSON.stringify(response3.data, (key, value) => {
// Handle nested objects and arrays
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
return Object.entries(value).reduce((acc, [k, v]) => {
acc[k] = v;
return acc;
}, {});
}
return value;
}, 2); // Optional parameter for pretty printing
// Log success message
console.log('Standings logged successfully.');
// Return the response data if needed
return stringifiedData;
} catch (error) {
// Handle any errors
console.error('Error fetching or saving matchup data:', error.response ? error.response.data : error.message);
return null;
}
}
// Call the async function to fetch the data
const response3Data = await fetchData();
console.log('Workflow Data:', response3Data);