Skip to content

Commit

Permalink
feat(zhi-fetch-middleware): add fetch middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 4, 2023
1 parent d69f1d0 commit 32b7066
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libs/zhi-fetch-middleware/src/lib/commonFetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ class CommonFetchClient {
*
* @param endpointUrl - 请求地址
* @param fetchOptions - 请求参数
* @param middlewareUrl - 可选,当环境不支持时候,必传
*/
public async fetchCall(endpointUrl: string, fetchOptions: RequestInit): Promise<any> {
public async fetchCall(endpointUrl: string, fetchOptions: RequestInit, middlewareUrl?: string): Promise<any> {
const apiUrl = this.requestUrl + endpointUrl
return await this.fetchRequest(apiUrl, fetchOptions)
return await this.fetchRequest(apiUrl, fetchOptions, middlewareUrl)
}

/**
Expand Down Expand Up @@ -94,8 +95,7 @@ class CommonFetchClient {

let resJson

const isTest = process.env.TEST === "true"
if (isTest || (typeof response !== "undefined" && response instanceof Response)) {
if (typeof response !== "undefined" && response instanceof Response) {
// 解析响应体并返回响应结果
const statusCode = response.status

Expand Down

0 comments on commit 32b7066

Please sign in to comment.