I have installed request-promise library and trying to use it in my TypeScript app but without much luck.
If I use it like this:
import {RequestPromise} from'request-promise';
RequestPromise('http://www.google.com')
.then(function (htmlString) {
// Process html...
})
.catch(function (err) {
// Crawling failed...
});
I see this on TS compile output:
error TS2304: Cannot find name 'RequestPromise'.
If I use it this way:
import * as rp from'request-promise';
rp('http://www.google.com')
.then(function (htmlString) {
// Process html...
})
.catch(function (err) {
// Crawling failed...
});
I see an error that says that there is no '.then()' method on object rp.
How do I properly use it with TypeScript?