<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> //console.dir(promise); function foo() { return new Promise(function(resolve, reject) { setTimeout(function() { resolve(123); }, 100) }) } foo() .then(function(data) { console.log(data); }) .catch(function(data) { console.log(data); }) .finally(function(data) { console.log('finished'); }) </script> </body> </html>