Sample code for 30+ languages & platforms
React Native

Inspect HTTP Request Header

Demonstrates the LastHeader property.

Chilkat React Native Downloads

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

async function chilkatExample() {
  const http = new Http();

  const url = 'https://chilkatsoft.com/echo_request_body.asp';
  const json = '{"greeting":"Hello World"}';

  // Send a POST with the JSON in the HTTP request body.
  const resp = new HttpResponse();
  try {
    await http.httpStrAsync('POST', url, json, 'utf-8', 'application/json', resp);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  // Examine the HTTP request header we just sent.
  console.log(http.lastHeader);

  // Output:

  // POST /echo_request_body.asp HTTP/1.1
  // Host: chilkatsoft.com
  // Accept: */*
  // Accept-Encoding: gzip
  // Content-Type: application/json
  // Content-Length: 26
}