Experimental Code Column uses Java script - Would it work with Python script?!

In case anyone wants the code to fetch data:

Here’s a revised JavaScript script for a GET request, tailored for use in Glide’s Experimental Code Column:

function getTotalSteps(token) {
const url = ‘https://exist.io/api/2/attributes/with-values/’;
const options = {
method: ‘GET’,
headers: {
‘Authorization’: Token ${token}
}
};

return fetch(url, options)
.then(response => response.json())
.then(data => {
    const today = new Date().toISOString().split('T')[0];
    const stepsAttribute = data.results.find(attr => attr.name === 'steps');
    const todayValue = stepsAttribute ? stepsAttribute.values.find(val => val.date === today) : null;
    return todayValue ? todayValue.value : 'No Data';
})
.catch(error => {
    console.error('Error:', error);
    return 'Error';
});

}

// Assuming token is in ‘p1’
return getTotalSteps(p1.value);

How This Script Works:

  1. URL and Headers: The script sets the URL for the Exist API and includes the necessary Authorization header with your token.
  2. GET Request: It performs a GET request to the Exist API.
  3. Processing the Response:
  • The script checks the current date.
  • It looks for the ‘steps’ attribute in the response data.
  • It then finds the value for today’s date.
  1. Returning the Result: The function returns the step count for today, or ‘No Data’ if no steps data is found for today.
  2. Error Handling: If there’s an error during the fetch process, the script catches it and returns ‘Error’.

Make sure to replace p1.value with the appropriate column name in your Glide table that contains the Exist API token. This script should work within the Glide Experimental Code Column to fetch and display today’s step count from the Exist API.

Here is an ugly screen that is using the result to update a glide chart: