Sample code for 30+ languages & platforms
React Native

Example: Http.QuickGetStr method

Demonstrates the QuickGetStr method.

Chilkat React Native Downloads

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

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

  // Keep the response body if there's an error.
  http.keepResponseBody = true;

  // Send the HTTP GET and return the content in a string.
  let str: string;
  try {
    str = await http.quickGetStrAsync('https://www.chilkatsoft.com/helloWorld.json');
  } catch {
    if (http.lastStatus === 0) {
      // Communications error.  We did not get a response.
      console.log(http.lastErrorText);
    } else {
      console.log(`Response status code: ${http.lastStatus}`);
      console.log('Response body error text:');
      console.log(http.lastResponseBody);
    }

    return;
  }

  console.log(str);
  console.log('Success');
}