修正 fetch
This commit is contained in:
parent
3d96075b34
commit
7e6c42cee8
|
|
@ -15,7 +15,7 @@ var AmapInstance = /** @class */ (function () {
|
|||
case 0:
|
||||
from = data.from, to = data.to;
|
||||
url = "http://restapi.amap.com/v3/direction/driving?origin=".concat(from[0].toFixed(6), ",").concat(from[1].toFixed(6), "&destination=").concat(to[0].toFixed(6), ",").concat(to[1].toFixed(6), "&strategy=10&key=").concat(this.key);
|
||||
return [4 /*yield*/, fetch(url)];
|
||||
return [4 /*yield*/, global.fetch(url)];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [4 /*yield*/, result.json()];
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ var QiniuCloudInstance = /** @class */ (function () {
|
|||
contentType = 'application/json';
|
||||
token = this.getLiveToken(method, path, host);
|
||||
url = "https://pili.qiniuapi.com/v2/hubs/".concat(hub, "/streams");
|
||||
return [4 /*yield*/, fetch(url, {
|
||||
return [4 /*yield*/, global.fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
|
|
@ -152,7 +152,7 @@ var QiniuCloudInstance = /** @class */ (function () {
|
|||
contentType = 'application/json';
|
||||
token = this.getLiveToken(method, path, host, rawQuery, contentType, bodyStr);
|
||||
url = "https://pili.qiniuapi.com".concat(path);
|
||||
return [4 /*yield*/, fetch(url, {
|
||||
return [4 /*yield*/, global.fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var WechatMpInstance = /** @class */ (function () {
|
|||
var response, headers, status, contentType, json, data;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, fetch(url, init)];
|
||||
case 0: return [4 /*yield*/, global.fetch(url, init)];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
headers = response.headers, status = response.status;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ var WechatPublicInstance = /** @class */ (function () {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
return [2 /*return*/, mockData];
|
||||
}
|
||||
return [4 /*yield*/, fetch(url, init)];
|
||||
return [4 /*yield*/, global.fetch(url, init)];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
headers = response.headers, status = response.status;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ var WechatWebInstance = /** @class */ (function () {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
return [2 /*return*/, mockData];
|
||||
}
|
||||
return [4 /*yield*/, fetch(url, init)];
|
||||
return [4 /*yield*/, global.fetch(url, init)];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
headers = response.headers, status = response.status;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class AmapInstance {
|
|||
)},${from[1].toFixed(6)}&destination=${to[0].toFixed(
|
||||
6
|
||||
)},${to[1].toFixed(6)}&strategy=10&key=${this.key}`;
|
||||
const result = await fetch(url);
|
||||
const result = await global.fetch(url);
|
||||
const jsonData = await result.json();
|
||||
if (jsonData.status !== '1') {
|
||||
throw new Error(JSON.stringify(jsonData));
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export class QiniuCloudInstance {
|
|||
const token = this.getLiveToken(method, path, host);
|
||||
|
||||
const url = `https://pili.qiniuapi.com/v2/hubs/${hub}/streams`;
|
||||
await fetch(url, {
|
||||
await global.fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
|
|
@ -201,7 +201,7 @@ export class QiniuCloudInstance {
|
|||
);
|
||||
|
||||
const url = `https://pili.qiniuapi.com${path}`;
|
||||
await fetch(url, {
|
||||
await global.fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export class WechatMpInstance {
|
|||
}
|
||||
|
||||
private async access(url: string, init?: RequestInit) {
|
||||
const response = await fetch(url, init);
|
||||
const response = await global.fetch(url, init);
|
||||
|
||||
const { headers, status } = response;
|
||||
if (![200, 201].includes(status)) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export class WechatPublicInstance {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
return mockData;
|
||||
}
|
||||
const response = await fetch(url, init);
|
||||
const response = await global.fetch(url, init);
|
||||
|
||||
const { headers, status } = response;
|
||||
if (![200, 201].includes(status)) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class WechatWebInstance {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
return mockData;
|
||||
}
|
||||
const response = await fetch(url, init);
|
||||
const response = await global.fetch(url, init);
|
||||
|
||||
const { headers, status } = response;
|
||||
if (![200, 201].includes(status)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue