I recently integrated the request-promise library into my TypeScript project, but I am facing some challenges in utilizing it effectively.
When attempting to use it in the following manner:
import {RequestPromise} from 'request-promise';
RequestPromise('http://www.google.com')
.then(function (htmlString) {
// Processing html...
})
.catch(function (err) {
// Crawling failed...
});
I encounter the following error during compilation:
error TS2304: Cannot find name 'RequestPromise'.
Alternatively, if I try using it like this:
import * as rp from 'request-promise';
rp('http://www.google.com')
.then(function (htmlString) {
// Processing html...
})
.catch(function (err) {
// Crawling failed...
});
An error is thrown indicating that there is no '.then()' method on the object rp.
Can someone provide guidance on the correct way to implement request-promise with TypeScript?