Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Function Written In Constructor Involving A Promise, Can Be Accessed As Below

class Person
 {
constructor(name)
{
this.name = name;
 const fn = async ()=>{
	let r =await fetch('/test', {method: 'POST', body: JSON.stringify({name:this.name}), headers: {'Content-type': 'application/json; charset=UTF-8'}})
return  r.json();
 } 
const result = fn();
return result;
}
}
 
PREVIOUS NEXT
Tagged: #Function #Written #In #Constructor #Involving #A #Can #Be #Accessed #As #Below
ADD COMMENT
Topic
Name
6+8 =