3 Commits

Author SHA1 Message Date
d2f50dcd3a Merge branch 'feature/log-api-endpoints' into 'marietje-zuid'
Add logging for API endpoints

Closes #74

See merge request technicie/MarietjeDjango!83
2024-05-06 13:46:52 +02:00
3f947a934c Merge branch 'fix/communicate-file-too-large' into 'marietje-zuid'
fix(songs): handle HTTP 413 and remove redundant .json() calls

Closes #76

See merge request technicie/MarietjeDjango!90
2024-04-23 19:09:55 +02:00
5c32fcb1d1 fix(songs): handle HTTP 413 and remove redundant .json() calls
Closes #76
2024-02-28 00:20:57 +01:00

View File

@ -179,13 +179,14 @@
}).catch(e => { }).catch(e => {
console.log(e); console.log(e);
if (e instanceof Response) { if (e instanceof Response) {
try { // Intercept an HTTP 413 error (entity too large), as this might
e.json().then(data => { // be thrown by a (reverse) proxy server and its payload is not
this.fileObjects[i].error_message = data.errorMessage; // nicely formatted as the code below expects.
this.fileObjects[i].success = false; if (e.status === 413) {
}); this.fileObjects[i].error_message = "The song you tried to upload is too large in size. (HTTP 413 error)";
} catch { this.fileObjects[i].success = false;
this.fileObjects[i].error_message = "An exception occurred while uploading this file, please try again."; } else {
this.fileObjects[i].error_message = `${e.statusText} (${e.status})`;
this.fileObjects[i].success = false; this.fileObjects[i].success = false;
} }
} else { } else {