0

Hi i try to get data from my web API with Angular but i get 404 not found the code is

Html code

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <meta charset="utf-8" />
    <title>Simple Web  Application</title>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/script.js"></script>
</head>
<body >
    <div ng-controller="MainController">
        <table>
            <tr>
                <td>ID</td>
                <td>Name</td>
            </tr>
            <tr ng-repeat="emp in employees">
                <td>{{emp.id}}</td>
                <td>{{emp.Ename}}</td>
            </tr>
        </table>
    </div>
</body>
</html>

Angular code:

var url = "http://localhost:65125/api/Empyloee";
var myApp = angular.module("myApp", []);

var MainController = function ($scope, $http) {
    var onSucess = function (response) { $scope.employees = response.data};
    var onFailure = function (reason) { $scope.error = reason };
    var getAllEmployees = function () {
        $http.get(url)
            .then(onSucess ,onFailure)
    };

    getAllEmployees();
};

myApp.controller("MainController", MainController);

thanks for the help

4
  • Please correct you question - paste code here and be more specific. Commented Oct 14, 2017 at 15:44
  • Any error in console? Where you able to data from API, please check network console.. Commented Oct 14, 2017 at 15:46
  • console show 404 not found work with postman without any problem Commented Oct 14, 2017 at 15:49
  • Are you sure your url is correct? You seem to have a typo in "http://localhost:65125/api/Empyloee" which I assume was meant to be Employee. So unless you have the same typo in your API endpoint, you'll get this 404 error. Commented Oct 14, 2017 at 18:31

1 Answer 1

2

It seems to be a problem with that endpoint in your API side. Re-test you API endpoint if it's working correctly. You can check response using POSTMAN before integrate with your angular solution.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the answer i verify my end point , and use POSTMAN and i get the data without any problem.
sometimes are missing "/" in url, or some mistake in the url. Try with another foo endpoint and integrate step by step your logic inside there if it is not too long.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.