Skip to content

Commit 0905d6d

Browse files
committed
Fix download shapefile
1 parent 2cbf076 commit 0905d6d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/components/LeftDrawerWms.vue

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,21 @@ export default {
275275
}
276276
277277
const downloadShapefile = async function () {
278-
const url = 'https://mapserver.mosquitoalert.com/geoserver/mosquitoalert/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=mosquitoalert:discoveries&outputFormat=SHAPE-ZIP'
278+
const url = 'https://mapserver.mosquitoalert.com/geoserver/mosquitoalert/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=mosquitoalert:discoveries&outputFormat=SHAPE-ZIP'
279279
loadingDownload.value = true
280-
fetch(url)
281-
.then(response => {
282-
exportFile('discoveries.shp', response)
283-
})
284-
.finally(() => {
285-
loadingDownload.value = false
286-
})
280+
281+
try {
282+
const response = await fetch(url)
283+
if (!response.ok) {
284+
throw new Error(`HTTP error! status: ${response.status}`)
285+
}
286+
const blob = await response.blob()
287+
exportFile('discoveries.zip', blob)
288+
} catch (err) {
289+
console.error('Failed to download shapefile:', err)
290+
} finally {
291+
loadingDownload.value = false
292+
}
287293
}
288294
289295
return {

0 commit comments

Comments
 (0)