React Native
React Native
HTTP POST JSON
See more HTTP Examples
Demonstrates how to send a JSON POST and get the JSON response.Chilkat React Native Downloads
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();
const jsonText = '{"user":"doctoravatar@penzance.com","forecast":7,"t":"vlIj","zip":94089}';
// IMPORTANT: Make sure to change the URL, JSON text,
// and other data items to your own values. The URL used
// in this example will not actually work.
const resp = new HttpResponse();
try {
await http.httpStrAsync('POST', 'https://json.penzance.org/request', jsonText, 'utf-8', 'application/json', resp);
} catch {
console.log(http.lastErrorText);
return;
}
// Display the JSON response.
console.log(resp.bodyStr);
}