TypeError: Cannot read properties of undefined (reading 'url') 에러가 뜹니다.
조회수 521회
setTimeout(function() {
var res3 = reqeust("POST", "https://typecast.ai/api/speak/batch/get", {
headers: {
"Authorization": `Bearer ${token}`
},
json: speak_url
})
var url = JSON.parse(res3.getBody("utf8")).result[0].audio.url;
이 부분에서
var url = JSON.parse(res3.getBody("utf8")).result[0].audio.url;
^
TypeError: Cannot read properties of undefined (reading 'url')
at Timeout._onTimeout (경로)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
이런 에러가 떠서 중간에 console.log를 넣어 확인해보니까 어떤 때는 "audio": {"url": "url"}가 있고 또 어떤 때는 없었습니다.
원래 자바스크립트 까막눈인데 사용하고 싶은 api가 어떤 분이 자바스크립트로 만드신 것 밖에 없어서 무리하게 도전했다가 혼자 해결도 못하고 있네요...
댓글 입력