import analytics from "@react-native-firebase/analytics" ; import fetch from "cross-fetch" ; const baseUrl = "https://gyanall.herokuapp.com/" ; const FetchBuilder = ( route , conf ) => { return new Promise ( async ( resolve , reject ) => { try { console . log ( baseUrl + route ) ; const rawResp = await fetch ( baseUrl + route , conf ) ; const resp = await rawResp . json ( ) ; console . log ( `Service->Gyan->${ route } response:` , resp . name ) ; resolve ( resp ) ; } catch ( err ) { console . log ( `Service->Gyan->${ route } error:` , err . message ) ; await analytics ( ) . logEvent ( "gyan-api-error" , { message : err . message , } ) ; reject ( err ) ; } } ) ; } ; export const getPlantDetails = ( name ) => { return new Promise ( async ( resolve , reject ) => { try { const resp = await FetchBuilder ( `${ name }` , undefined ) ; resolve ( resp ) ; } catch ( err ) { reject ( err ) ; } } ) ; } ;