If you'd like request to return a Promise instead, you can use an alternative interface wrapper for request.
It then proceeds to suggest request-promise-native for native Promises.
The problem is that the request-promise-native package's documentation is minimal, and will probably mislead most request users who are simply looking to promisify their code.
Specific examples include:
the documentation says that you need to npm install both request and request-promise-native, but then fails to indicate that your code should require('request-promise-native') rather than require('request'). This might seem minor, but it's likely to be very confusing to newcomers from request.
the API appears to be quite different, but there is no documentation to this effect. For example, to retrieve content-type from request.head is rc.headers.get('content-type') but with request-promise-native is rc['content-type']
As it stands, I suspect the casual request user would be better-served by simply using util.promisify. It would be good to write some basic documentation.
The
request
package suggests that:It then proceeds to suggest
request-promise-native
for native Promises.The problem is that the
request-promise-native
package's documentation is minimal, and will probably mislead mostrequest
users who are simply looking to promisify their code.Specific examples include:
require('request-promise-native')
rather thanrequire('request')
. This might seem minor, but it's likely to be very confusing to newcomers from request.rc.headers.get('content-type')
but with request-promise-native isrc['content-type']
As it stands, I suspect the casual
request
user would be better-served by simply usingutil.promisify
. It would be good to write some basic documentation.