15 lines
431 B
TypeScript
15 lines
431 B
TypeScript
import * as Bluebird from 'bluebird'
|
|
import * as request from 'request'
|
|
|
|
function doRequest <T> (
|
|
requestOptions: request.CoreOptions & request.UriOptions
|
|
): Bluebird<{ response: request.RequestResponse, body: T }> {
|
|
return new Bluebird<{ response: request.RequestResponse, body: T }>((res, rej) => {
|
|
request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))
|
|
})
|
|
}
|
|
|
|
export {
|
|
doRequest
|
|
}
|