mirror of
https://github.com/xfarrow/blink
synced 2025-04-14 16:51:58 +02:00
better API error handling
This commit is contained in:
parent
b2abaf7685
commit
35f04d70df
@ -61,7 +61,7 @@
|
|||||||
document.cookie = `token=${data.token};`;
|
document.cookie = `token=${data.token};`;
|
||||||
window.location.href = 'userprofile.html?id=me';
|
window.location.href = 'userprofile.html?id=me';
|
||||||
} else {
|
} else {
|
||||||
alert(data.error);
|
callbackErrors(data.errors, alert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Sign Up to Blink</title>
|
<title>Sign Up to Blink</title>
|
||||||
<link rel="stylesheet" href="../css/login-register.css">
|
<link rel="stylesheet" href="../css/login-register.css">
|
||||||
<script src=""></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -77,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
window.location.href = '/login.html';
|
window.location.href = '/login.html';
|
||||||
} else {
|
} else {
|
||||||
alert(data.error);
|
callbackErrors(data.errors, alert);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -8,4 +8,8 @@ function getCookie(name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function callbackErrors(errors, func) {
|
||||||
|
errors.forEach(error => func(error.msg));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user