Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Promise Method
- function http(url, method) {
- var promise = new Promise(function(resolve, reject) {
- setTimeout(function() {
- var data = '42';
- if (data) {
- resolve(data);
- }
- else {
- reject("No Data");
- };
- }, 1000);
- });
- return promise;
- };
- http("http://google.com", "GET", function(data) {
- console.log(data);
- }, function(err) {
- console.log(err);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement