Compare commits

...

2 Commits

Author SHA1 Message Date
Daniel Waxweiler d9d3a98cec
Merge 183c7bdd35 into 3269ccca1a 2024-04-04 21:02:00 +00:00
Daniel Waxweiler 183c7bdd35 check response 2024-04-04 23:01:49 +02:00
1 changed files with 6 additions and 2 deletions

View File

@ -28,7 +28,6 @@ export default ({ attributes, setAttributes }) => {
timer = setTimeout(() => {
const container = document.getElementById(blockProps.id)
if (container) {
// TODO not using newest values yet, can get out of sync
hideErrorMessages(container)
clearEventsList(container)
showLoadingIndicator(container)
@ -37,7 +36,12 @@ export default ({ attributes, setAttributes }) => {
url += `&groupName=${groupName}`
}
fetch(url)
.then((response) => response.text()) // TODO also handle response.ok being false
.then((response) => {
if (!response.ok) {
return Promise.reject('Network response was not OK.')
}
return response.text()
})
.then((data) => {
const events = JSON.parse(data)
displayEvents({