Я пытаюсь получить данные из веб-API, используя параметр. Я не могу получить data.no также не отображается сообщение об ошибке.
компонент панели приборов
Countrymodel: Country = {country_id: '', название страны: '', статус: false} Страны: наблюдаемые;
constructor(private api: RestApiService, private router: Router) { }
ngOnInit() {
let currentUserName = localStorage.getItem('currentUserName');
console.log(currentUserName);
this.GetCountry(currentUserName);
}
GetCountry(currentUserName: string) {
this.Countries = this.api.getcountry(currentUserName);
console.log(this.Countries);
}
}
api.service
export class RestApiService {
Url = 'http://localhost:xxxx/Api/Example/';
header: any;
constructor(private http: HttpClient) {
const headerSettings: { [name: string]: string | string[]; } = {};
this.header = new HttpHeaders(headerSettings);
}
getcountry(currentUserName: string): Observable<Country[]> {
console.log(this.Url + 'GetCountry?Username=' + currentUserName);
return this.http.get<Country[]>(this.Url + 'GetCountry?Username=' + currentUserName);
}
WebApi
[Route("Api/Example/GetCountry")]
[HttpGet]
public IHttpActionResult GetCountry(string Username)
{
}