0

I have not been able to get async/await working in a react native project.

const async getUser = () => {
  try{
    let value = await AsyncStorage.getItem("user");
    return value;
  }
  catch(e){
    throw e
  }
}

I always get an Unexpected token error. I have tried adding { "presets": ["react-native", "es2015", "babel-preset-stage-3"] } with the same result.

On version ^0.35.0

1 Answer 1

3

The syntax for async arrow functions is:

const getUser = async () => {
  ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.