Reputation: 31
I am using angular js and sails js in my project. I am getting problem with http get() while sending data with special characters from angular to sails.
I want to use http post() instead of http get(). Can anybody help ? My code looks like
var employee = $scope.employee;
$http({
method: 'POST',
url: '/employee/saveEmployee',
headers: {'Content-Type': 'application/json'},
data: {"empName":"employee .empName",
"age":"employee .age",
"designation":"employee .designation",
"empType":"employee .empType"
}
}).success(function (data) {
alert(data);
});
Upvotes: 1
Views: 578
Reputation: 31
Its worked ....I have put the json in improper format.
Just removed the Double code " " from Json like this::
data: {
empName:employee .empName,
age:employee .age,
designation:employee .designation,
empType:employee .empType
}
Upvotes: 0
Reputation: 6221
If you are using a sails generated API, just change your url to /employee/create
Sails automatically generates standard CRUD routes that you can use out of the box.
Upvotes: 1