Reputation: 33
I am just trying to call my .net core API function from my Angular v5.2.0 app and i getting "GET http://localhost:5000/api/values net::ERR_CONNECTION_REFUSED zone.js:3243"
This is my component.js file which i'm using to call the api.
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'app-value',
templateUrl: './value.component.html',
styleUrls: ['./value.component.css']
})
export class ValueComponent implements OnInit {
values: any;
constructor(private http: Http) {
}
ngOnInit() {
this.GetValues();
}
GetValues() {
this.http.get('http://localhost:5000/api/values').subscribe(response => {
console.log(response);
});
}
}
This is the error i'm getting. enter image description here
Upvotes: 1
Views: 1214
Reputation: 554
Does your UI(angular) code and api run on same port
I can see in image the UI runs on localhost:4200 and you are trying to call api on localhost:5000
make sure localhost:5000 is up and running and try to get data with any client such as postman.
Upvotes: 2