Currently, my goal is to retrieve data from an API using an interface. I have created a temporary interface as shown below:
export interface ITemp {
id: number,
name: string,
age: number
}
Furthermore, I have an HTTP service where there is a function called getHomeDetails that makes a call to the API:
import {Injectable} from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ITemp } from "../interfaces/temp";
import { Observable } from "rxjs/Observable";
import 'rxjs/Rx';
@Injectable()
export class HttpService{
http:any;
baseUrl: String;
constructor(http:HttpClient){
this.http = http;
this.baseUrl = 'some_url';
}
getHomeDetails(): Observable<ITemp> {
return this.http.get<ITemp>(this.baseUrl); //issue arises here
//when hovering over get<ITemp>, I receive a "Untyped function calls may not accept type arguments" error
}
}
I am facing an issue where the interface is not being properly defined. I am unsure of what mistake I am making. It is worth noting that the syntax used above is specific to Angular version 4.3X. The code editor tools I am utilizing are Sublime Text and Visual Studio.