React Native
React Native
qa.factura1.com.co Obtain Auth Token
See more HTTP Misc Examples
Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.coChilkat React Native Downloads
import { Http, HttpResponse, JsonObject } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
// Build the following JSON
// {
// "password": "MY_PASSWORD",
// "username": "MY_USERNAME"
// }
const json = new JsonObject();
json.emitCompact = false;
json.updateString('password', 'MY_PASSWORD');
json.updateString('username', 'MY_USERNAME');
const resp = new HttpResponse();
try {
await http.httpJsonAsync('POST', 'https://qa.factura1.com.co/v2/auth', json, 'application/json', resp);
} catch {
console.log(http.lastErrorText);
return;
}
const jsonResp = new JsonObject();
jsonResp.emitCompact = false;
jsonResp.load(resp.bodyStr);
console.log(jsonResp.emit());
console.log(`Access token: ${jsonResp.stringOf('token')}`);
}