File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,12 @@ function onErrorFetchNewsFlash() {
68
68
return errorArr ;
69
69
}
70
70
71
- export function updateNews (
71
+ export const updateNews = async (
72
72
newsId : number ,
73
73
newLocationQualification : any ,
74
74
streetLocation : IStreetData | null ,
75
75
gpsLocation : IGpsData | null
76
- ) {
76
+ ) : Promise < any > => {
77
77
const payload : any = {
78
78
newsflash_location_qualification : newLocationQualification ,
79
79
} ;
@@ -87,8 +87,12 @@ export function updateNews(
87
87
}
88
88
89
89
const url = `${ NEWS_FLASH_API } /${ newsId } ` ;
90
- return axios
91
- . patch ( url , payload , { withCredentials : true } )
92
- . then ( ( res ) => res . data )
93
- . catch ( onErrorFetchNewsFlash ) ;
94
- }
90
+
91
+ try {
92
+ const response = await axios . patch ( url , payload , { withCredentials : true } ) ;
93
+ return response . data ;
94
+ } catch ( error ) {
95
+ console . error ( 'Error updating newsflash:' , error ) ;
96
+ return onErrorFetchNewsFlash ( ) ;
97
+ }
98
+ } ;
You can’t perform that action at this time.
0 commit comments