I have just updated my streamlit app from 1.35 to 1.37 but I am getting an error while clicking a button which fetches data from an api and displays it on a toast.
Bad message format
Bad ‘setIn’ index 1 (should be between [0, 0])
This is code which is being used for this work:
@st.cache_data(show_spinner=False)
def retrieve_data(fd,td):
api = "http://api.com"
post_data = {
"starttime":fd,
"endtime":td
}
response = requests.post(api,data=post_data)
return response
@st.cache_data(ttl=10,show_spinner=False)
def how_many_calls(fd,td):
response = retrieve_data(fd,td)
if response.status_code == 200:
data = response.json()['msg']
df = pd.DataFrame(data)
total_calls = len(data)
message = f"#### Total calls: {total_calls}"
else:
message = "Error"
return message
@st.fragment()
def check_total_calls():
actual_call_button = st.button("Actual Calls?",use_container_width=True)
if actual_call_button:
msg = how_many_calls(st.session_state.from_datetime,st.session_state.to_datetime)
st.toast(msg)
check_total_calls()
Earlier in version 1.35 it was all working fine. Dont know what happened now!!