React Native
React Native
SugarCRM Logout
See more SugarCRM Examples
Demonstrates how to logout of a session.Chilkat React Native Downloads
import { JsonObject, Rest, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
const rest = new Rest();
try {
await rest.connectAsync('your.site.domain', 443, true, true);
} catch {
console.log(rest.lastErrorText);
return;
}
rest.addHeader('Cache-Control', 'no-cache');
rest.addHeader('OAuth-Token', '<access_token>');
const sbReq = new StringBuilder();
const sbJson = new StringBuilder();
try {
await rest.fullRequestSbAsync('POST', '/rest/v10/oauth2/logout', sbReq, sbJson);
} catch {
console.log(rest.lastErrorText);
return;
}
if (rest.responseStatusCode !== 200) {
console.log(`Received error response code: ${rest.responseStatusCode}`);
console.log('Response body:');
console.log(sbJson.getAsString());
return;
}
const json = new JsonObject();
json.loadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
json.boolOf('success');
// A sample JSON response body that is parsed by the above code:
// {
// "success": true
// }
console.log('Example Completed.');
}