0
Good morning, I’m trying to access my API through the angular method get
of the http module, my files are in my repository github in case anyone wants to take a look. I am following this tutorial here
to make the request, but always give the following error:
ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
src/app/app.component.ts(2,10): error TS2305: Module '"/home/danielhgimenez/app-test/node_modules/rxjs/Observable"' has no exported member 'Observable'.
src/app/app.component.ts(3,27): error TS2307: Cannot find module 'app/pacoteAPI'.
src/app/app.component.ts(4,28): error TS2307: Cannot find module 'app/app.service'.
src/app/app.component.ts(18,3): error TS2663: Cannot find name 'dados'. Did you mean the instance member 'this.dados'?
src/app/app.service.ts(4,10): error TS2305: Module '"/home/danielhgimenez/app-test/node_modules/rxjs/Observable"' has no exported member 'Observable'.
src/app/app.service.ts(17,14): error TS2339: Property 'map' does not exist on type 'Observable<Response>'.
I don’t know how to fix this problem. Apparently it’s caused by me using the latest version of the angular and it needs this compatibility library, or it was removed in the new version (I don’t know for sure). I had "managed to arrange" (if you know what I mean) installing the packages npm install rxjs@6 rxjs-compat@6 --save
and using the command npm audit fix --force
to fix installation errors, but later continued to give error.
All I need is to make a request get on a localhost server that will return a JSON, take the json data and show on screen. I accept any suggestions to resolve the issue, and thank you if someone has a link with a newer article or one that better teaches you how to make a request.
From now on, thank you for your attention :)
Recently you updated your design for angular 6?
– Marconi
The command
npm install rxjs@6 rxjs-compat@6 --save
that you rode was necessary, this allows you to maintain compatibility with versions prior to version 6 without having to change your code. Where hasimport { Observable } from 'rxjs/Observable';
exchange forimport { Observable } from 'rxjs';
– Marconi