app.service('UserCRUDService',['$http', function ($http) {
this.getUser = function getUser(userId){
return $http({
method: 'GET',
url: 'users/'+userId
});
}
this.addUser = function addUser(name, email){
return $http({
method: 'POST',
url: '/users',
data: {name:name, email:email}
});
}
this.deleteUser = function deleteUser(id){
return $http({
method: 'DELETE',
url: 'users/'+id
})
}
this.updateUser = function updateUser(id,name,email){
return $http({
method: 'PATCH',
url: 'users/'+id,
data: {name:name, email:email}
})
}
this.getAllUsers = function getAllUsers(){
return $http({
method: 'GET',
url: 'users'
});
}
}]);
Mam taki kod. Generalnie wysyłanie POSTa działa, aczkolwiek jeżeli apka stoi na localhost:8080 to funkcja addUser uderzy pod localhost:8080/users. Moje pytanie brzmi jak zrobić aby można było wysłać POSTa pod inny adres np: localhost:8090/users. Oczywiście wpisywałem to w polu url, aczkolwiek wtedy w ogóle się nie wysyła.