I am creating a user profile page where user can edit their information, i am able to fetch the values from api but i am unable to update them. Below is the code i am implementing for updating, check it out and tell me whether i am doing it right or not.
$scope.update = function(user){
if($localStorage.hasOwnProperty("accessToken") === true) {
var requestContent = $.param({
email: user.email,
password: user.password,
facebook_url: user.facebook_url,
twitter_username: user.twitter_username
});
var req = {
method: 'PUT',
url: link+'user/profile?id='+$localStorage.accessToken,
data: requestContent,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}
$http(req).success(function(data) {
console.log(data.message);
console.log(data.user)
// $scope.profileData = data.user['name'];
$scope.profileData = data.user;
$ionicLoading.hide();
}).error(function(data) {
console.log(data.message);
$ionicLoading.hide();
});
} else {
console.log($localStorage.accessToken);
console.log(data.message);
$ionicLoading.hide();
}
};