mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 04:11:10 +00:00
Changes callApiPutAsync to return a success flag alongside the response data
This commit is contained in:
1 parent
d78e553fe2
commit
95be37602a
3 files changed
+8
-7
No files matched your search
@@ -109,7 +109,7 @@ async function callApiPostAsync(url, data, options = {}) {
|
||||
* @param {Object} [options] - Additional options for the request.
|
||||
* @param {boolean} [options.useAntiForgery=true] - Whether to include anti-forgery token.
|
||||
* @param {Object} [options.headers] - Additional headers to include.
|
||||
* @returns {Promise<any>} The response data if successful, undefined otherwise.
|
||||
* @returns {Promise<{success: boolean, data: any}>} The result of the request, containing the success flag and the response data.
|
||||
*/
|
||||
async function callApiPutAsync(url, data, options = {}) {
|
||||
const defaultOptions = {
|
||||
@@ -146,7 +146,7 @@ async function callApiPutAsync(url, data, options = {}) {
|
||||
if (jsonResponse.success) {
|
||||
if (jsonResponse.message)
|
||||
notificationService.show(jsonResponse.message, NotificationType.SUCCESS);
|
||||
return jsonResponse.data;
|
||||
return { success: jsonResponse.success === true, data: jsonResponse.data };
|
||||
}
|
||||
else
|
||||
notificationService.show(jsonResponse.errorMessage, NotificationType.ERROR);
|
||||
@@ -155,6 +155,7 @@ async function callApiPutAsync(url, data, options = {}) {
|
||||
console.error('Error:', error);
|
||||
notificationService.show(error, NotificationType.ERROR);
|
||||
}
|
||||
return { success: false };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user