It appears that the issue you are facing is as follows:
Compiled with problems:X
ERROR
src/app/services/data.service.ts:14:23 - error NG2003: No suitable injection token for parameter 'url' of class 'DataService'.
Consider using the @Inject decorator to specify an injection token.
14 constructor(private url: string, private http: HttpClient) {}
~~~
src/app/services/data.service.ts:14:28
14 constructor(private url: string, private http: HttpClient) {}
~~~~~~
This type is not supported as injection token.
The DataService class (which is extended by PostService) should not be marked as injectable. Making a class injectable means it can be provided and injected as a dependency. However, this should not be done in this case as DataService serves the purpose of providing a shape or a reusable service to avoid duplication.
To resolve this issue, you can comment out the Injectable decorator in DataService:
// @Injectable({
// providedIn: 'root',
// })
export class DataService {
constructor(private url: string, private http: HttpClient) {}
The revised PostService code should look like this:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { DataService } from './data.service';
@Injectable({
providedIn: 'root',
})
export class PostService extends DataService {
constructor(http: HttpClient) {
super('https://jsonplaceholder.typicode.com/posts', http);
}
}