Technology Sharing

The front-end interface returns a Promise

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

A pop-up window prompt needs to be returned in the project, the following code:

const onProductSubmit = async () => {
  const followById = await Open1688Api.updateProductFollowById(formData);
  console.log('followById : ' + followById.toString())
  alert(followById)
}
  • 1
  • 2
  • 3
  • 4
  • 5

Output promise
insert image description here

reason:

After calling the interface, no result is returned

solution:

Adding async and await

const onProductSubmit = async () => {
  const followById = await Open1688Api.updateProductFollowById(formData);
  console.log('followById : ' + followById.toString())
  alert(followById)
}
  • 1
  • 2
  • 3
  • 4
  • 5