While hitting my post api hit i am getting this above mentioned error , i tried a lot by following few of the links but didn't get any output , when i try to solve this error by adding bellow code in my app.js file.
app
.config(function($httpProvider, $stateProvider, $urlRouterProvider) {
$httpProvider.defaults.headers.common['Access-Control-Allow-Headers'] = '*';
});
This is how i am hitting my post api :-
$http
.post(
'http://www.mastersoftwaretechnologies.com:90/restapi/customer/setaddress/',
{
firstname : $scope.data.full_name,
lastname : $scope.data.last_name,
street : $scope.data.address,
city : $scope.data.city_name,
country_id : $scope.user.country,
region : $scope.data.state,
postcode : $scope.data.pin_name,
telephone : $scope.data.phone_name
})
.then(
function(response) {
$ionicLoading.hide();
alert(JSON.stringify(response));
$scope.data.full_name = '';
$scope.data.last_name = '';
$scope.data.address = '';
$scope.data.city_name = '';
$scope.user.country = '';
$scope.data.state = '';
$scope.data.pin_name = '';
$scope.data.phone_name
$state.go('app.paymethod');
}
Error :- My data is not getting passed to server its going blank.
But when i hit this api from postman the data is getting entered in server and on hit on getaddress api i am getting the same address which i entered in setaddress api (in case of post-man its working but in my device it's not).
Can any body tell me how to resolve this error do i need to add some more headers at my end or do i need to add headers on server end ?
Please provide me some solution.
Thanks.