How to use await key word on react native?

I’m using async/await in my react native app and didn’t have to do anything to configure or enable it in my project. My usage takes the form of…

async getCache(key){
    try{
        let value = await AsyncStorage.getItem(key);
        return value.json();
    }
    catch(e){
        console.log('caught error', e);
        // Handle exceptions
    }

}

Note:
If you use an await inside a function that is not explicitly declared with async, you’ll end up with an Unexpected token syntax error.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)