File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
nextjs/src/features/organization/helper Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,16 @@ export interface City {
2929}
3030
3131export const fetchCountries = async ( ) : Promise < Country [ ] > => {
32- const response = await getAllCountries ( )
33- const { data } = response as AxiosResponse
34-
35- if ( data ?. statusCode === apiStatusCodes . API_STATUS_SUCCESS ) {
36- return data ?. data || [ ]
32+ try {
33+ const response = await getAllCountries ( )
34+ const { data } = response as AxiosResponse
35+ return data ?. statusCode === apiStatusCodes . API_STATUS_SUCCESS
36+ ? data . data || [ ]
37+ : [ ]
38+ } catch ( error ) {
39+ console . error ( 'Error fetching countries:' , error )
40+ return [ ]
3741 }
38- throw new Error ( data ?. message || 'Failed to fetch countries' )
3942}
4043
4144export const fetchStates = async ( countryId : number ) : Promise < State [ ] > => {
You can’t perform that action at this time.
0 commit comments