Handle error thrown in postConfigUpdateToAPI (#3299)
Co-authored-by: Tiffany L <tleugn@wpi.edu>
This commit is contained in:
@@ -54,15 +54,22 @@ const TEXTFIELD_TYPE_URL = 'url';
|
|||||||
|
|
||||||
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
||||||
const { apiPath, data, onSuccess, onError } = args;
|
const { apiPath, data, onSuccess, onError } = args;
|
||||||
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
try {
|
||||||
data,
|
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
||||||
method: 'POST',
|
data,
|
||||||
auth: true,
|
method: 'POST',
|
||||||
});
|
auth: true,
|
||||||
if (result.success && onSuccess) {
|
});
|
||||||
onSuccess(result.message);
|
if (result.success && onSuccess) {
|
||||||
} else if (onError) {
|
onSuccess(result.message);
|
||||||
onError(result.message);
|
} else if (onError) {
|
||||||
|
onError(result.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (onError) {
|
||||||
|
onError(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user