Where is Promise in request-promise?
See original GitHub issueI can’t understand where is a promise
in a request-promise
. How do I get a promise
object, not a Request
object?
let rp = require('request-promise');
let p = rp('https://example.com/');
console.log('p', p);
// p is not a promise, it is Request!
Request {
domain: null,
...
_sessionCache: { map: {}, list: [] } } }
How do I get a promise
object? I need it to create an array of promises. But instead I get an array of Requests.
Object.keys(array).map(id => {
return rp('https://example.com/' + id); // I expect this to be a Promise, not a Request
});
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
request-promise - npm
The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.. Latest version: 4.2.6, last published: 2 years ago.
Read more >Node.js promise request return - Stack Overflow
A promise is an object that serves as a placeholder for a future value. Your parse() function returns that promise object.
Read more >request-promise JavaScript and Node.js code examples
Most used request-promise functions · RequestPromise.then · RequestPromise.catch · RequestPromise.pipe · RequestPromise.bind · RequestPromise.finally.
Read more >How to Make API Requests with Request-Promise in Node.js
... of this tutorial for links to prerequisites and related tutorials: https://heynode.com/tutorial/how-make-api-requests- request - promise...
Read more >How to get node.js HTTP request promise without a single ...
const getContent = function(url) { // return new pending promise return new Promise((resolve, reject) => { // select http or https module, depending...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @wzup , it is actually both!
What you get is the original request object plus
.then(...)
,.catch(...)
, and.finally(...)
attached. If you want to userequest(...).spread(...)
for example then do this:request(...).promise().spread(...)
But if you just need standard promise capabilities like in your use case withmap
you can work withrp('https://example.com/' + id)
directly since the returned object has a.then(...)
method.Further details see here.
Anything else I can answer for you?
@BentOnCoding Yes there is:
rp(...).promise()