mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
check response
This commit is contained in:
@@ -28,7 +28,6 @@ export default ({ attributes, setAttributes }) => {
|
|||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
const container = document.getElementById(blockProps.id)
|
const container = document.getElementById(blockProps.id)
|
||||||
if (container) {
|
if (container) {
|
||||||
// TODO not using newest values yet, can get out of sync
|
|
||||||
hideErrorMessages(container)
|
hideErrorMessages(container)
|
||||||
clearEventsList(container)
|
clearEventsList(container)
|
||||||
showLoadingIndicator(container)
|
showLoadingIndicator(container)
|
||||||
@@ -37,7 +36,12 @@ export default ({ attributes, setAttributes }) => {
|
|||||||
url += `&groupName=${groupName}`
|
url += `&groupName=${groupName}`
|
||||||
}
|
}
|
||||||
fetch(url)
|
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) => {
|
.then((data) => {
|
||||||
const events = JSON.parse(data)
|
const events = JSON.parse(data)
|
||||||
displayEvents({
|
displayEvents({
|
||||||
|
Reference in New Issue
Block a user