Handle error thrown in postConfigUpdateToAPI (#3299)
Co-authored-by: Tiffany L <tleugn@wpi.edu>
This commit is contained in:
@@ -54,6 +54,7 @@ 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;
|
||||||
|
try {
|
||||||
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
||||||
data,
|
data,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -65,6 +66,12 @@ export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
|||||||
onError(result.message);
|
onError(result.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (onError) {
|
||||||
|
onError(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Some default props to help build out a TextField
|
// Some default props to help build out a TextField
|
||||||
export const TEXTFIELD_PROPS_SERVER_NAME = {
|
export const TEXTFIELD_PROPS_SERVER_NAME = {
|
||||||
|
|||||||
Reference in New Issue
Block a user