make typescript-fetch code compatiable with nodejs environment (#10072)

This commit is contained in:
duxiaofeng
2021-08-06 14:59:40 +08:00
committed by GitHub
parent 75181210d5
commit c05ec99182
12 changed files with 24 additions and 24 deletions

View File

@@ -74,7 +74,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -137,7 +137,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {

View File

@@ -85,7 +85,7 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
@@ -148,7 +148,7 @@ export class Configuration {
}
get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
return this.configuration.fetchApi;
}
get middleware(): Middleware[] {