Skip to content

Commit

Permalink
docs: update docs:
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt committed Dec 27, 2023
1 parent 3223a20 commit 098d175
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions docs/reference/plugin/plugins/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,28 @@

```js
import { defineRuntimeConfig } from '@fesjs/fes';
import { isPlainObject } from 'lodash-es';

export default defineRuntimeConfig({
request: {
// API 前缀
baseURL: '',
dataHandler(data, response) {
// 处理响应内容异常
if (data.code !== '0') {
if (data.code === '10000')
FMesseage.error('hello world');

if (data.code === '20000')
FMesseage.error('hello world');

throw new Error(response);
if (isPlainObject(data)) {
// 处理响应内容异常
if (data.code !== '0') {
if (data.code === '10000')
FMesseage.error('hello world');

if (data.code === '20000')
FMesseage.error('hello world');

throw new Error(response);
}
// 响应数据格式化
return data?.result ? data.result : data;
}
// 响应数据格式化
return data?.result ? data.result : data;
return data;
},
// http 异常,和插件异常
errorHandler(error) {
Expand Down

0 comments on commit 098d175

Please sign in to comment.