Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Promises basic structure

let p = new Promise ((resolve, reject) => {

	let a = 1 + 1;
    
    if (a === 2) {
    	resolve("Success");
    } else {
    	reject("Fail");
    };
});

p.then((message) => {
	console.log('This is the then' + message);

}).catch ((message) => {
	console.log('This is in the catch' + message);
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: js map iterate 
Javascript :: fullscreen mode javascript 
Javascript :: typeface in gatsby 
Javascript :: remove time from date in node js 
Javascript :: javascript onkeyup multiple classes 
Javascript :: jquery url change 
Javascript :: update angular cli 10 
Javascript :: js add week to date 
Javascript :: binary to ascii javascript 
Javascript :: javascript check if value exists in array of objects 
Javascript :: mongoose required 
Javascript :: how to call a javascript function in html without any event 
Javascript :: statements and expressions in js 
Javascript :: fetch in js 
Javascript :: Create slug from string in Javascript 
Javascript :: react open a link to an outside siite 
Javascript :: mm dd yyyy how to get date in this format in javascript 
Javascript :: hover event javascript 
Javascript :: jschlatt 
Javascript :: adonis join with multi condictions 
Javascript :: how to focus icon of active screen react native 
Javascript :: sort an array by the laster letter of element javascript 
Javascript :: jquery set title 
Javascript :: bootstrap selectpicker get selected value 
Javascript :: Javascript Remove Element By Id Code Example 
Javascript :: javascript check if first of type 
Javascript :: how to only accept email in the format of name@domain.com js 
Javascript :: React Navigation back() and goBack() not working 
Javascript :: get url parameter in react js 
Javascript :: json opposite of stringify 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =