FEATURE: Show alert when AJAX call failed

This commit is contained in:
Dominique Barton 2019-02-22 01:13:36 +01:00
parent 28f8704422
commit 55e0418883

View file

@ -15,7 +15,11 @@ class API {
init = { method: 'POST', body: data }
fetch(endpoint, init).then(function(response) {
return response.json();
let obj = response.json()
if(response.status == 200)
return obj
else
window.alert(obj.message)
}).then(callback)
}