Do we need proxypass to access express back end from angular front end when using 2 separate ports in localhost.
<div class="row" ng-controller="UserController">
<table class="table">
<thead>
<tr>
<th>First name</th>
<th>Last name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
</tr>
</tbody>
</table>
</div>
angular.module('PharmacyApp').factory('UserService', ['$http',
function ($http) {
return {
get: () => $http.get('/users').then(response => response.data),
add: user => $http.post('/users', user).then(response => response.data),
getById: id => $http.get('/users/' + id).then(response => response.data),
addComment: (id, comment) => $http.post('/users/' + id + '/comments', comment).then(response => response.data),
};
}]);
Using localhost:4000 I want to invoke a function within a controller in my back-end from Frontend. How to do that?