前端调接口返回了Promise

项目中需要返回一个弹窗提示,下面代码:

const onProductSubmit = async () => {
  const followById = await Open1688Api.updateProductFollowById(formData);
  console.log('followById : ' + followById.toString())
  alert(followById)
}

输出promise
在这里插入图片描述

原因:

接口调用之后没有等到返回结果

解决方案:

增加async和await

const onProductSubmit = async () => {
  const followById = await Open1688Api.updateProductFollowById(formData);
  console.log('followById : ' + followById.toString())
  alert(followById)
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 18:48:04       53 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 18:48:04       56 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 18:48:04       46 阅读
  4. Python语言-面向对象

    2024-07-11 18:48:04       57 阅读

热门阅读

  1. 设计模式六大原则

    2024-07-11 18:48:04       18 阅读
  2. PG延迟模拟和查看

    2024-07-11 18:48:04       17 阅读
  3. el-date-picker 禁用 之前 和 之后 的时间

    2024-07-11 18:48:04       18 阅读
  4. 【66个开源+44个闭源Agent项目】

    2024-07-11 18:48:04       16 阅读
  5. 网络安全领域红蓝对抗里关于红队全方位解析

    2024-07-11 18:48:04       20 阅读
  6. GitHub Copilot & API

    2024-07-11 18:48:04       17 阅读
  7. 【linux】log 保存和过滤

    2024-07-11 18:48:04       17 阅读
  8. OpenCV和CUDA匹配,使用源码构建OpenCV

    2024-07-11 18:48:04       20 阅读
  9. Oracle左连接过滤条件注意事项

    2024-07-11 18:48:04       18 阅读