Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Created July 27, 2018 00:27
Show Gist options
  • Save CreatiCoding/899346e111cfb163f84a43972bbf7a94 to your computer and use it in GitHub Desktop.
Save CreatiCoding/899346e111cfb163f84a43972bbf7a94 to your computer and use it in GitHub Desktop.
[Node.js] request with promise
const request = require('request');
new Promise((resolve, reject)=>{
console.log(1);
resolve(new Promise((resolve, reject)=>{
request({url:'http://www.naver.com'},()=>{
console.log(2);
resolve(3);
});
}));
}).then(data=>{
console.log(data);
});
@CreatiCoding
Copy link
Author

output

1
2
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment