@seayoo-web/web-api
v2.2.6
Published
agent for web api
Readme
Web Api Agent
import { ComboPublicApi, AccountWebApi } from "@seayoo-web/web-api";
import { NetRequest } from "@seayoo-web/request";
import { captureException } from "@sentry/vue";
// 创建 combo api 实例
const comboApi = new ComboPublicApi(SY_COMBO_API, NetRequest);
comboApi.req.setConfig({
messageHandler(_, message) {
toast(message);
},
errorHandler({ rawError, sentryError, sentryTags, sentryExtra }) {
// 意外错误进行上报
if (rawError) {
captureException(sentryError, {
extra: sentryExtra,
tags: sentryTags,
});
}
},
});
// 创建 account api 实例
const accountApi = new AccountWebApi(SY_ACCOUNT_API, NetRequest);
accountApi.req.setConfig({
messageHandler(_, message) {
toast(message);
},
errorHandler({ rawError, sentryError, sentryTags, sentryExtra }) {
// 意外错误进行上报
if (rawError) {
captureException(sentryError, {
extra: sentryExtra,
tags: sentryTags,
});
}
},
});
// 导出实例供其他模块使用
export { comboApi, accountApi };