Data service exception in ASP.NET Boilerplate (Core 2.0 + Angular 5) Free Template

90 views Asked by At

I created a test API that returns a sample string in the .NET application and it has been working well using REST API clients like Postman. But when I try to retrieve the data via data service in Angular app in the boilerplate and try to console.log the response, I got an exception as shown below:

Exception when loading the component

Basically I added a simple class in the service-proxy.ts file where almost all the services are stored in the app.

@Injectable()

export class TestService {

    constructor(private http: Http){

    }

    testRetrieve(){
        return this.http.get('http://localhost:21021/api/services/app/User/GetTest');
    }
}

Then I added the class in the module file, service-proxy.module.ts and inject it in the user component to call the function in the constructor like this:

constructor(
    injector: Injector,
    private _userService: UserServiceProxy,
    private tstSrv: TestService
) {
    super(injector);
    this.tstSrv.testRetrieve().subscribe(res => console.log);
}

I have no idea why it's giving me this kind of error. I cannot write any simpler code in Angular than this. The testRetrieve() function returns just a simple observable, and I just need to subscribe() to that. But still, something is going wrong in the background, and the app is looking for then somewhere down the line.

Anyone any idea?

0

There are 0 answers