I am currently a beginner studying JavaScript.
The code is debugged below, and "letres_=await this.callApi("
)
If the callApi is undefined, you will get in trouble.
There is no description of callApi in the code below, but
It certainly describes "let values = wait this.callApi(this.METHOD.GET,..."
I don't understand why I get scolded for undefined because I have been able to execute the part.
How do I write it down to load it?
Could you teach me?Thank you for your cooperation.
async test(){
const {hennsu1,hennsu2,hennsu3} = this.info;
// Get global IP
const network_info = wait fetch (this.GET_GLOBAL_IP)
.then(res=>res.json())
let values = wait this.callApi(this.METHOD.GET,`${this.URL_ENDPOINT.AAAA}/${this.AAAA.XXXXXX}`);
varcamera_url='"
var success_code = this.STATUS_CODE.SUCCESS
if(values&values.code==this.STATUS_CODE.SUCCESS){
let duration = null
bootbox.prompt({
title —This.title,
message —This.message,
inputType: 'radio',
inputOptions: [{
text:values.payload[0].explanation,
value: values.payload[0].value
},
{
text:values.payload[1].explanation,
value: values.payload[1].value
}],
callback:async function (result) {
if(result!=null){
letres_=wait this.callApi(
this.METHOD.GET,
`${this.URL_ENDPOINT.xxx}/${network_info.ip}/${result}/${hennsu1}/${hennsu2}`);
if(res_&res_.code==success_code){
camera_url=`http://${res_.payload.xxxx}:${res_.payload.xxxxX}/${hennsu3===null?':hennsu3}`;
window.open(camera_url, '_blank');
}
}
}
});
} else{
constmsg=res&res.message?res.message:this.UNEXPECTED_ERR;
bootbox.alert(msg);
}
},
This callback: What
is called depends on the this
becomes when async function(result){bootbox.prompt()
specification implementation.
Fix this
by changing to the Arrow function or adding .bind(this)
.
© 2024 OneMinuteCode. All rights reserved.