Home > front end >  Unexpected reserved word 'await' for react native
Unexpected reserved word 'await' for react native

Time:01-10

Hi theres error on paypal for react native. I got this code from a documentation for paypal-react-native. The code is not working for some reason Here is the Code

const {
    nonce,
    payerId,
    email,
    firstName,
    lastName,
    phone
  } = await requestOneTimePayment(
    token,
    {
      amount: '5',
      currency: 'GBP',
      shippingAddressRequired: false,
      userAction: 'commit',   
      intent: 'authorize', 
    }
  );

CodePudding user response:

await is a promise that you are returning a value, and the rest of your code will not run until it has completed.

It can only be used within asynchronous functions.

async function asyncCall() {
  console.log('calling');
  const result = await resolveAfter2Seconds();
  console.log(result);
  // expected output: "resolved"
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

  •  Tags:  
  • Related