import AsyncStorage from "@react-native-community/async-storage" ; param { string } key returns { Promise . < string > } export async function GetStorageItemString ( key ? ) { if ( ! key ) { return Promise . reject ( new Error ( "Input parameter 'Key' is required" ) ) ; } return getItem ( key ) . then ( result => { if ( result === null ) { return Promise . reject ( new Error ( `Storage item '${ key }' does not exist` ) ) ; } return result ; } ) ; async function getItem ( key ) { if ( navigator && navigator . product === "ReactNative" ) { return AsyncStorage . getItem ( key ) ; } if ( window ) { const value = window . localStorage . getItem ( key ) ; return Promise . resolve ( value ) ; } return Promise . reject ( new Error ( "No storage API available" ) ) ; } }