Within one of the services in my Angular application, I have utilized the map()
function to retrieve data from the GitHub API.
getUser(username: string) {
// Regular Expression used for String Manipulation
return this.http.get('https://api.github.com/users/'.concat(username))
.map(res => res);}
However, when attempting to invoke this method as shown below,
this.githubService.getUser('dasunpubudumal')
.subscribe(user => {
console.log(user.created_at); });
My WebStorm IDE is indicating a red line under the created_at attribute. The message reads TS2339 Property created_at does not exist on type 'Object'. Nevertheless, upon running the code, it successfully outputs the created_at field from the JSON object returned by the endpoint.
Am I making an error in some way? Is there a solution to resolve this error? I am utilizing the HttpClient module for making requests to these endpoints.