Updated api fetch to return an object.

This commit is contained in:
Mike Cao committed 2020-09-30 15:14:44 -07:00
1 parent e64b35f701
commit e5cd162b83
10 files changed
+28 -28

No files matched your search

+3 -5
View File
@@ -40,15 +40,13 @@ export default function ChangePasswordForm({ values, onSave, onClose }) {
const [message, setMessage] = useState();
const handleSubmit = async values => {
const response = await post(`/api/account/password`, values);
const { ok, data } = await post(`/api/account/password`, values);
if (typeof response !== 'string') {
if (ok) {
onSave();
} else {
setMessage(
response || (
<FormattedMessage id="message.failure" defaultMessage="Something went wrong." />
),
data || <FormattedMessage id="message.failure" defaultMessage="Something went wrong." />,
);
}
};