本文整理汇总了TypeScript中@csegames/camelot-unchained.webAPI.TraitsAPI.GetTraitsV1方法的典型用法代码示例。如果您正苦于以下问题:TypeScript webAPI.TraitsAPI.GetTraitsV1方法的具体用法?TypeScript webAPI.TraitsAPI.GetTraitsV1怎么用?TypeScript webAPI.TraitsAPI.GetTraitsV1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@csegames/camelot-unchained.webAPI.TraitsAPI
的用法示例。
在下文中一共展示了webAPI.TraitsAPI.GetTraitsV1方法的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,
}));
}
}
});
};