Skip to content

Commit

Permalink
Modify error handling in js: using Promise.reject
Browse files Browse the repository at this point in the history
  • Loading branch information
JustineFricou committed May 6, 2024
1 parent ac82486 commit a09f744
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions geotrek/core/static/core/multipath.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,17 +506,21 @@ L.Handler.MultiPath = L.Handler.extend({
})
})
.then(response => {
// console.log("response", response)
if (response.status == 200)
return response.json()
return Promise.reject(response)
})
.then(data => {
// console.log('response data:', data)
if (data) {
var route = {'geojson': data}
this.fire('fetched_route', route);
}
})
.then(
data => { // Status code 200:
console.log('response data:', data)
if (data) {
var route = {'geojson': data}
this.fire('fetched_route', route);
}
},
// If the promise was rejected:
response => console.log("fetchRoute:", response)
)
// .catch(e => {
// console.log("fetchRoute", e)
// })
Expand Down

0 comments on commit a09f744

Please sign in to comment.