mirror of
https://github.com/owncast/owncast.git
synced 2024-11-27 09:45:36 +03:00
Handle error thrown in postConfigUpdateToAPI (#3299)
Co-authored-by: Tiffany L <tleugn@wpi.edu>
This commit is contained in:
parent
c815b8ebf4
commit
cbbc219091
1 changed files with 16 additions and 9 deletions
|
@ -54,15 +54,22 @@ const TEXTFIELD_TYPE_URL = 'url';
|
|||
|
||||
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
||||
const { apiPath, data, onSuccess, onError } = args;
|
||||
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
||||
data,
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
});
|
||||
if (result.success && onSuccess) {
|
||||
onSuccess(result.message);
|
||||
} else if (onError) {
|
||||
onError(result.message);
|
||||
try {
|
||||
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
|
||||
data,
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
});
|
||||
if (result.success && onSuccess) {
|
||||
onSuccess(result.message);
|
||||
} else if (onError) {
|
||||
onError(result.message);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
onError(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue