Here is my code.
import { injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/catch';
@Injectable({
providedIn: 'root'
})
export class PostsService {
private url = 'https://jsonplaceholder.typicode.com/posts';
constructor(private http : Http ) { }
getPosts {
return this.http.get(this.url);
}
deletePost(id) {
return this.http.get(this.url + '/' + id);
}
}
I am doing this code on my PC it's working but not working on a laptop. It seems funny but this is true.
This is the structure of my project
To solve the error "Module not found: Error: Can't resolve 'rxjs'", make sure to install the rxjs package by opening your terminal in your project's root directory and running the command npm install rxjs and restart your development server.
The rxjs-compat package was created so that developers could upgrade to RxJS version 6 without having to modify code. It re-implements the prototype-patching operators and makes available all of the RxJS-version-5 export locations.
New version of rxjs no longer supports single imports, instead try:
import { catchError } from 'rxjs/operators';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With