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
});
if (res.ok) {
const json = await res.json();
if (res.ok && json.error === undefined) {
setOpen(true);
setSeverity('success');
setMessage(`File uploaded! ${window.location.protocol}//${window.location.host}${route}/${await res.text()}`);
setMessage(`File uploaded! ${json.url}`);
} else {
const json = await res.json();
setOpen(true);
setSeverity('error');
setMessage('Could not upload file: ' + json.error);
@ -86,4 +85,4 @@ export default function Manage({ route }) {
</Box>
</>
);
}
}