기술나눔

프런트 엔드 디버깅 인터페이스가 Promise를 반환했습니다.

2024-07-12

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

프로젝트는 다음 코드와 같은 팝업 프롬프트를 반환해야 합니다.

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

출력 약속
여기에 이미지 설명을 삽입하세요.

이유:

인터페이스를 호출한 후에는 결과가 반환되지 않습니다.

해결책:

비동기를 추가하고 기다립니다

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