Fixed error/url not showing properly (#85)
* Fixed error not showing. * Update Upload.tsx
This commit is contained in:
parent
dacf13e46d
commit
474024ea55
1 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||||
|
@ -86,4 +85,4 @@ export default function Manage({ route }) {
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue