@capacitor-community/http post request with empty response

Viewed 502

I am developing ionic application and using @capacitor-community/http plugin for API call.

When I call POST request which returns some response, it's working perfect.

But when I call POST request which returns empty response, it throws exception JSONException at Object.cap.fromNative.

Find below my API call.

import { Http } from '@capacitor-community/http';

const config = {'Content-Type': 'application/json',
      'X-CLIENT-AUTHORIZATION': token
};
      const options = {
        url: url,
        headers: config,
        data: postBody,
      };
      
      return Http.post(options).then(res => {
        console.log(res);
        return res;
      }).catch(err => {
        console.log(err);
      });

Kindly help me on this.

0 Answers
Related