forked from tanner/qotnews
feat: Display detailed submission errors to user
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -17,13 +17,17 @@ function Submit() {
|
||||
data.append('url', url);
|
||||
|
||||
fetch('/api/submit', { method: 'POST', body: data })
|
||||
.then(res => res.json())
|
||||
.then(res => res.json().then(data => ({ ok: res.ok, data })))
|
||||
.then(
|
||||
(result) => {
|
||||
history.replace('/' + result.nid);
|
||||
({ ok, data }) => {
|
||||
if (ok) {
|
||||
history.replace('/' + data.nid);
|
||||
} else {
|
||||
setProgress(data.error || 'An unknown error occurred.');
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
setProgress('Error');
|
||||
setProgress(`Error: ${error.toString()}`);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user