Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Create A Promise And Then Return It


let fetchSent =	fetch("/test", {method:"POST", body: JSON.stringify({name:"NAME NAME NAME"}), headers: {'Content-type': 'application/json; charset=UTF-8'}});
const p1 = new Promise((resolve, reject) => {
  resolve(fetchSent);
  // or
  // reject(new Error("Error!"));
})
	 

 return p1;
/*console.log(p1) will yield the fetch promise that was sent to you*/
Source by worcraft-algeria-dz.com #
 
PREVIOUS NEXT
Tagged: #Create #A #Promise #And #Then #Return #It
ADD COMMENT
Topic
Name
9+7 =