Search
 
SCRIPT & CODE EXAMPLE
 

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());
	 

 
}
 
Comment

PREVIOUS NEXT
Code Example
Javascript :: Declare Function To Be Used In Class 
Javascript :: dayofyear mongodb 
Javascript :: JavaScript Using es6(ES2015) Destructuring assignment 
Javascript :: call the httpclient.get method called 
Javascript :: Turn A 2D Array Into A JSON 
Javascript :: nested object data 
Javascript :: how to skip the else statment in react tertiary 
Javascript :: nestjs prisma controller 
Javascript :: function titleCase 2 
Javascript :: animation in react stack overflow 
Javascript :: PostManDocs 
Javascript :: leetcode solution problem 66 plus one 
Javascript :: The most obvious example is handling the click event, 
Javascript :: get the first recurring character javascript 
Javascript :: Different Pages For Different Routes In Backbone 
Javascript :: React Futures - Server Components 
Javascript :: Solution-4--solution options for reverse bits algorithm js 
Javascript :: javascript odd or even 
Javascript :: react native raw bottom sheet 
Javascript :: get class name of object javascript 
Javascript :: window location href 
Javascript :: javascript last element 
Javascript :: static in class javascript 
Javascript :: react 18.2 
Javascript :: react native file pdf to base64 
Javascript :: js add obj prop dynamically 
Javascript :: javascript Adding Element to the Inner Array 
Javascript :: javascript setTimeout() method returns the interval id 
Javascript :: Save multiple Child 
Javascript :: nodejs: http: router simple 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =