本文整理匯總了TypeScript中@csegames/camelot-unchained.webAPI.TraitsAPI類的典型用法代碼示例。如果您正苦於以下問題:TypeScript webAPI.TraitsAPI類的具體用法?TypeScript webAPI.TraitsAPI怎麽用?TypeScript webAPI.TraitsAPI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了webAPI.TraitsAPI類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getTraits
async function getTraits(dispatch: (action: any) => any, payload: FetchTraitInterface) {
const config: RequestConfig = () => ({
url: payload.apiHost,
headers: {
Authorization: `${client.ACCESS_TOKEN_PREFIX} ${patcher.getAccessToken()}`,
},
});
const res = await webAPI.TraitsAPI.GetTraitsV1(config, client.shardID);
if (res.ok) {
const data = JSON.parse(res.data);
dispatch(onInitializeTraits({
playerClass: _.trim(payload.playerClass),
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
initType: payload.initType,
}));
} else {
toastr.error(
'We are having technical difficulties. You will not be able to create a character until they have been fixed.',
'Oh No!!',
{ timeOut: 5000 },
);
}
}
示例2: return
return (dispatch: (action: any) => any) => {
const config: RequestConfig = () => ({
url: payload.apiHost,
headers: {
Authorization: `${client.ACCESS_TOKEN_PREFIX} ${patcher.getAccessToken()}`,
},
});
return webAPI.TraitsAPI.GetTraitsV1(config, client.shardID)
.then((result) => {
const data = JSON.parse(result.data);
if (result.ok) {
if (payload.initType === 'boons') {
dispatch(onResetBoons({
playerClass: payload.playerClass,
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
}));
}
if (payload.initType === 'banes') {
dispatch(onResetBanes({
playerClass: payload.playerClass,
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
}));
}
if (payload.initType === 'both') {
dispatch(onResetBoons({
playerClass: payload.playerClass,
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
}));
dispatch(onResetBanes({
playerClass: payload.playerClass,
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
}));
}
}
});
};