Sample code for 30+ languages & platforms
React Native

POST application/json HTTPS Request

See more HTTP Examples

Demonstrates how to send an HTTPS POST where the request body and response body both have the application/json Content-Type. Also demonstrates how to add a few custom headers to the request.

Chilkat React Native Downloads

React Native
import { Http, HttpResponse } from '@chilkat/react-native'

async function chilkatExample() {
  // This requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code

  const http = new Http();

  // Add a few custom headers.
  http.setRequestHeader('Client-ID', 'my_client_id');
  http.setRequestHeader('Client-Token', 'my_client_token');

  http.accept = 'application/json';

  const url = 'https://api.fiscallog.eu/sign/v1';
  const jsonRequestBody = '{ .... }';
  const resp = new HttpResponse();
  try {
    await http.httpStrAsync('POST', url, jsonRequestBody, 'utf-8', 'application/json', resp);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  console.log(`Response status code = ${resp.statusCode}`);
  const jsonResponseStr = resp.bodyStr;

  console.log(jsonResponseStr);
}