1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

fix showing group not found error in block

This commit is contained in:
Daniel Waxweiler
2025-05-23 21:21:04 +02:00
parent 3e2aac7657
commit 10f4f3eceb
4 changed files with 13 additions and 16 deletions

View File

@ -39,7 +39,14 @@ export default ({ attributes, setAttributes }) => {
}
container.querySelector('a').href = showMoreUrl
await fetch(url)
.then((response) => response.text())
.then(async (response) => {
if (!response.ok) {
// Reject if no 2xx response.
const data = await response.text()
return Promise.reject(data)
}
return response.text()
})
.then((data) => {
const events = JSON.parse(data)
displayEvents({
@ -50,7 +57,8 @@ export default ({ attributes, setAttributes }) => {
})
})
.catch((data) => {
displayErrorMessage({ data, container })
const parsedData = JSON.parse(data)
displayErrorMessage({ data: parsedData, container })
})
}
}, 500)