Skip to content Skip to sidebar Skip to footer

Convert Json As Formurl Encoded Data Using Transformrequest

I am trying to convert JSON data as formURL encoded data but still, it isn't working. My HTTP post $http.post(API_ENDPOINT.login, credentials, { transformRequest: transformRequ

Solution 1:

Due to 5da1256, transformRequest functions can no longer modify request headers. This behavior was unintended and undocumented, so the change should affect very few applications.

To send a POST request with Content-Type: application/x-www-form-urlencoded:

var config = {
  transformRequest: $httpParamSerializer,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
};

$http.post(API_ENDPOINT.login, credentials, config)
  .then(function(response) {
    console.log("SUCCESS");
}).catch(function(response) {
    console.log("ERROR");
    throw response;
});

Post a Comment for "Convert Json As Formurl Encoded Data Using Transformrequest"