0

I created a angular 9 project with Angular CLI 9.1.5.

I install with npm in this project the request-promise library.

I start with :

npm i request --save
npm i @type/request
npm i request-promise --save
npm i @type/request-promise

When i run this project, i have a lot of error but i found online a solution, in my package.json i add :

"browser": {
"crypto": false,
"http": false,
"https": false,
"net": false,
"path": false,
"stream": false,
"tls": false,
"os": false,
"zlib": false,
"fs": false
}

In my tsconfigconfig.app.json

I add :

"types" : ["node"]

In my service i use :

import * as rp from 'request-promise';
export class test{
    rpget(){

        rp.get('xxxxxxxxxx').then(function(response2){
            // expect(response.statusCode).toBe('GET /200');
            /* console.log("respnse " + response2);

            }).catch(function(error) {
            console.log(error);
            });
            }
}

When i run ng serve, compilation ending but in the browser console i have the following error :

undefined###undefined### The "request" library is not installed automatically anymore.undefined### But is a dependency of "request-promise".undefined### Please install it with:undefined### npm install request --saveundefined###undefined

But request is installed in this project.

cody_code
  • 1
  • 1
  • Why not use the built in `HttpClient`? It returns an `Observable` but rxjs has a `toPromise` operator to convert the obserable to a promise. https://www.learnrxjs.io/learn-rxjs/operators/utility/topromise – Jason White May 26 '20 at 14:53
  • Because my code is finished with request-promise. I want to do webscraping. With HttpClient can I webscrape a website? – cody_code May 27 '20 at 09:41
  • Can you help me pliz? – cody_code May 29 '20 at 11:12

0 Answers0