useMiscs()
The useMiscs()
composable allows for fetching and storing miscellaneous data such as titles.
This feature might be extended in the future
In SAP Commerce Cloud, miscellaneous data also includes card types, currencies and languages. Although the useMiscs()
composable allows to only fetch titles at the moment, its scope might be extended in the future.
titles
Main data object populated by the loadTitles()
method.
Type
const titles: ComputedProperty<Title[]>
References: Title
loading
Indicates whether any of the composable methods is in progress.
Type
const loading: ComputedProperty<UseMiscsLoading>;
References: UseMiscsLoading
error
Contains errors thrown by any of the composable methods.
Type
const error: ComputedRef<UseMiscsError>;
References: UseMiscsError
loadTitles()
Fetches a list of localized titles from the API and saves them to the titles property. Under the hood, it sends a request to the getTitles API endpoint.
Type
async function loadTitles(props?: BaseProps): Promise<void>;
References: BaseProps
Example
In this example, we are fetching a list of localized titles and specify a subset of fields which should be returned with the response.
import { useMiscs } from '@vsf-enterprise/sapcc';
import { onMounted } from '@nuxtjs/composition-api';
export default {
setup() {
const { titles, loadTitles } = useMiscs();
onMounted(async () => {
await loadTitles({ fields: 'name' });
});
return { titles };
}
};