I am following a tutorial, and through check and recheck, I am 100% sure my code is exactly equal to the one the professor is using. We are making a simple Single Page Application in Angular, which, presumably, involves typescript.
I'm pretty sure all external classes are correctly written, and VS Code points no other error in the written code except for the following script in my file feed.component.ts The ideia is to define an attribute listPost (of type array and class Post[]) which recieves the list of post objects contained in an adress specified in the class PostService.
To be more precise, the problem I'm dealing with is in the function findPosts(), for which it says there is an error pointed as "complete () => void" (which I have no idea what means). One thing is disturbing me is that this is written EXACTLY as in the professor files. The only one difference is that he's using Typescript v. 3.9.2 whilst I'm with v. 4.3.2. I suspect that might be an issue, since for what I've searched typescript has a lot of issues when interpreting different versions.
import { Component, OnInit } from '@angular/core';
import { PostService } from '../service/post.service';
import { Post } from '../model/Post'
@Component({
selector: 'app-feed',
templateUrl: './feed.component.html',
styleUrls: ['./feed.component.css']
})
export class FeedComponent implements OnInit {
private listPost: Post[];
constructor(private postService: PostService) {
this.listPost = []
}
ngOnInit(): void {
this.findPosts()
}
findPosts() {
this.postService.getPosts()
.subscribe(
(data: Post[]) => {this.listPost = data} );
}
}