Advertisement
soden

Untitled

Feb 27th, 2024 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.30 KB | Source Code | 0 0
  1. function getData() {
  2.     return new Promise(function(resolve, reject) {
  3.         setTimeout(function() {
  4.             resolve('Data berhasil diambil');
  5.         }, 2000);
  6.     });
  7. }
  8.  
  9. getData().then(function(message) {
  10.     console.log(message);
  11. }).catch(function(error) {
  12.     console.error(error);
  13. });
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement