Returns the currently selected travel destination as a lowercase ISO 3166-1 alpha-2 country code.
The selected travel destination lowercase ISO 3166-1 alpha-2 country code when available.
Simple usage
import { UserAttributesModule, isSuccess, isErrorResponse } from '@grabjs/superapp-sdk';
// Initialize the user attributes module
const userAttributes = new UserAttributesModule();
// Read the selected travel destination
const response = await userAttributes.getSelectedTravelDestination();
// Handle the response
if (isSuccess(response)) {
switch (response.status_code) {
case 200:
console.log('Selected travel destination code:', response.result);
break;
case 204:
console.log('Selected travel destination is not available');
break;
}
} else if (isErrorResponse(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
JSBridge module for reading user-related attributes from native code.
Remarks
Provides access to user and traveller attributes exposed by the native Grab app bridge. This code must run on the Grab SuperApp's WebView to function correctly.
Example
ES Module:
Example
CDN (UMD):