Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Create A Class That Returns A Promise In Constructor

class Person


{
constructor(name)
{
	this.name = name;
let r =  fetch("/test", {method:"POST", body: JSON.stringify({x: this.name}),    headers:{'Content-type': 'application/json; charset=UTF-8'}});
return r;

}


 

}

async function run()
	 { 
const p = new Person("john smith");
let r = await p;
 

console.log(await r.json());
	 

 
}
 
 
PREVIOUS NEXT
Tagged: #Create #A #Class #That #Returns #A #Promise #In #Constructor
ADD COMMENT
Topic
Name
2+8 =