Not able to send http post in ionic


#1

here is how i used to send http post request in ionic 1
$scope.UpdateUser = function (existingUser) {

  var customerData = {};

  customerData = {
    "studentImage": existingUser.studentImage,
    "parentImage": existingUser.parentImage,
    "guardianImage": existingUser.guardianImage,
    "studentId": existingUser.studentId,
    "campusName": existingUser.campusShortCode,
    "campusId": existingUser.campusId,
    "fatherPhNo": existingUser.fatherPhNo,
    "motherPhNo": existingUser.motherPhNo,
    "landline": existingUser.landline,
    "fatherEmail": existingUser.fatherEmail,
    "motherEmail": existingUser.motherEmail,
    "address": existingUser.address,
  }

  var headers = {
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
    'Content-Type': 'multipart/form-data',
    'Accept': 'application/json'
  };
  var req = {
    method: 'POST',
    url: 'http://campusshiksha.com/shiksha/EditStudentFromApp',
    headers: headers,
    // data: { studentImage: 'studentImage',  parentImage: 'parentImage', guardianImage: 'guardianImage', studentId: 'studentId', campusName: 'campusName', campusId: 'campusId', fatherPhNo: 'fatherPhNo', motherPhNo: 'motherPhNo', landline: 'landline', fatherEmail: 'fatherEmail', motherEmail: 'motherEmail', address: 'address',}
    data: customerData
  }

  $http(req).success(function (res) {
    console.log(res);
    $scope.response = res;
    console.log(customerData);
  })
    .error(function (res) { $scope.response = "res.data"; });
}

con someone help me convert the above code to ionic 3


#2

Read the Tour of Heroes.