React Native
React Native
Send a Bodyless REST Request into a StringBuilder
See more REST Examples
Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.
Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.
Chilkat React Native Downloads
import { Rest, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
const rest = new Rest();
const bTls = true;
const bAutoReconnect = true;
try {
await rest.connectAsync('example.com', 443, bTls, bAutoReconnect);
} catch {
console.log(rest.lastErrorText);
return;
}
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
const sbResponse = new StringBuilder();
try {
await rest.fullRequestNoBodySbAsync('GET', '/api/items/123', sbResponse);
} catch {
console.log(rest.lastErrorText);
return;
}
let responseText: string;
try {
responseText = sbResponse.getAsString();
} catch {
console.log(sbResponse.lastErrorText);
return;
}
console.log(responseText);
}