I’m facing difficulties in resolving this issue. I created a web API using .NET, and now I’m attempting to call this API in an Angular project.
//movie.ts
export class Movie{
ID: number;
Title: number;
GenreId: number;
Duration: number;
RatingScore: number;
PublishDate: Date;
}
//movieservice.ts
import { Injectable, Inject } from "@angular/core";
import {HttpClient} from "@angular/common/http"
import {} from "@angular/core/"
import { Movie } from "../models/movie";
@Injectable({
providedIn: 'root'
})
export class MovieserviceeService {
constructor(private httpClient: HttpClient, @Inject("url") private url: string) { }
GetAll() {
return this.httpClient.get(this.url + "Movies");
}
GetSingle(id: number) {
return this.httpClient.get(this.url + "Movies/" + id);
}
PostAdd(personel: Movie) {
return this.httpClient.post(this.url + "Movies", personel);
}
PutUpdate(personel: Movie) {
return this.httpClient.put(this.url + "Movies/", personel);
}
Remove(id: number) {
return this.httpClient.delete(this.url + "Movies?id=" + id);
}
}
//appmovie.component.ts
import { Component, OnInit } from '@angular/core';
import {Movie} from "../../models/movie"
import { MovieserviceeService } from 'src/app/services/movieservicee.service';
@Component({
selector: 'app-appmovie',
templateUrl: './appmovie.component.html',
styleUrls: ['./appmovie.component.css']
})
export class AppmovieComponent implements OnInit {
movieList: Movie[];
movie: Movie;
constructor(private MovieserviceeService: MovieserviceeService){}
ngOnInit(): void {
throw new Error('Method not implemented.');
}
GetAll()
{
this.MovieserviceeService.GetAll().subscribe((response: Movie[]) => {this.movieList = response; });
}
}
Upon running the code, I encountered the following error:
No overload matches this call... https://i.sstatic.net/vUXjf.png