Fixed error/url not showing properly (#85)

* Fixed error not showing.

* Update Upload.tsx
This commit is contained in:
Nguyen Thanh Quang 2021-08-23 22:39:31 +07:00 committed by GitHub
parent dacf13e46d
commit 474024ea55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,13 +30,12 @@ export default function Manage({ route }) {
}, },
body body
}); });
const json = await res.json();
if (res.ok) { if (res.ok && json.error === undefined) {
setOpen(true); setOpen(true);
setSeverity('success'); setSeverity('success');
setMessage(`File uploaded! ${window.location.protocol}//${window.location.host}${route}/${await res.text()}`); setMessage(`File uploaded! ${json.url}`);
} else { } else {
const json = await res.json();
setOpen(true); setOpen(true);
setSeverity('error'); setSeverity('error');
setMessage('Could not upload file: ' + json.error); setMessage('Could not upload file: ' + json.error);