Sunday, March 19, 2017

Using Laravel 5.4 route in AngularJS $http service

I'm using Laravel 5.4 and AngularJS. I have this function :

$scope.allPosts = function() {
        $http.get("/posts")
            .then(function(response){
                $scope.posts = response.data;
            }, function(err){
                console.log(err);
            });
};

How can I avoid using hardcoded "/posts" and instead using a Laravel route there ?

Thank you.



via dwix

Advertisement