Skip to content

Commit

Permalink
Merge pull request #37 from zven21/feature/add-credentials-desc
Browse files Browse the repository at this point in the history
Add a parameter description for credentials in README.md file.
  • Loading branch information
clock157 authored Apr 2, 2019
2 parents 683065f + fba794e commit 362f8f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ For more discussion, refer to [Traditional Ajax is dead, Fetch eternal life](htt
| suffix | suffix, such as some scenes api need to be unified .json | string | -- |
| errorHandler | exception handling, or override unified exception handling | function(error) | -- |
| headers | fetch original parameters | object | -- | {} |
| credentials | fetch request with cookies | string | -- | credentials: 'include' |

The other parameters of fetch are valid. See [fetch documentation](https://github.github.io/fetch/)

Expand Down
5 changes: 3 additions & 2 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
| prefix | 前缀, 一般用于覆盖统一设置的prefix | string | -- | -- |
| suffix | 后缀, 比如某些场景 api 需要统一加 .json | string | -- | -- |
| errorHandler | 异常处理, 或者覆盖统一的异常处理 | function(error) | -- |
| headers | fetch 原有参数 | object | -- | {} |
| headers | fetch 原有参数 | object | -- | {} |
| credentials | fetch 请求包含 cookies 信息 | object | -- | credentials: 'include' |

fetch原其他参数有效, 详见[fetch文档](https://github.github.io/fetch/)

Expand Down Expand Up @@ -193,7 +194,7 @@ const errorHandler = (error) => {
const { response, data } = error;
message.error(codeMap[data.errorCode]);

throw error; // 如果throw. 错误将继续抛出.
throw error; // 如果throw. 错误将继续抛出.
// return {some: 'data'}; 如果return, 将值作为返回. 不写则相当于return undefined, 在处理结果时判断response是否有值即可.
}

Expand Down

0 comments on commit 362f8f1

Please sign in to comment.