【问题标题】:Unexpected reserved word 'await' for react native反应本机的意外保留字“等待”
【发布时间】:2023-03-12 16:53:02
【问题描述】:

您好,paypal 上的 react native 出现错误。我从 paypal-react-native 的文档中获得了此代码。该代码由于某种原因无法正常工作 这是代码

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

【问题讨论】:

    标签: javascript android reactjs react-native


    【解决方案1】:

    await 是一个承诺,您将返回一个值,并且您的其余代码在完成之前不会运行。

    它只能在异步函数中使用。

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 2021-12-08
      • 2021-10-03
      • 1970-01-01
      • 2021-05-08
      • 2016-06-14
      相关资源
      最近更新 更多