@jd-data-limited/easy-fm 3.2.9 → 3.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jd-data-limited/easy-fm",
3
- "version": "3.2.9",
3
+ "version": "3.2.11",
4
4
  "dependencies": {
5
5
  "follow-redirects": "^1.15.5",
6
6
  "moment": "^2.29.4",
@@ -100,6 +100,8 @@ export class Database extends EventEmitter {
100
100
  if (!options.headers)
101
101
  options.headers = {};
102
102
  options.headers["content-type"] = options.headers["content-type"] ? options.headers["content-type"] : "application/json";
103
+ if (options.headers["content-type"] === "multipart/form-data")
104
+ delete options.headers["content-type"]; // Delete this header so that it can be automatically reconstructed
103
105
  options.headers["authorization"] = "Bearer " + this._token;
104
106
  options.rejectUnauthorized = this.host.verify;
105
107
  let _fetch = yield fetch(url, options);
@@ -112,6 +112,7 @@ export class Database<T extends DatabaseStructure> extends EventEmitter implemen
112
112
  async apiRequest<T = any>(url: string | Request, options: any = {}, autoRelogin = true): Promise<ApiResults<T>> {
113
113
  if (!options.headers) options.headers = {}
114
114
  options.headers["content-type"] = options.headers["content-type"] ? options.headers["content-type"] : "application/json"
115
+ if (options.headers["content-type"] === "multipart/form-data") delete options.headers["content-type"] // Delete this header so that it can be automatically reconstructed
115
116
  options.headers["authorization"] = "Bearer " + this._token
116
117
  options.rejectUnauthorized = this.host.verify
117
118
 
@@ -131,7 +131,7 @@ export class Field {
131
131
  yield this.record.layout.database.apiRequest(`${this.record.endpoint}/containers/${this.id}/1`, {
132
132
  method: "POST",
133
133
  // @ts-ignore
134
- headers: { "Authorization": "Bearer " + this.record.layout.database.token, "Content-Type": "multipart/form-data" },
134
+ headers: { "content-type": "multipart/form-data" },
135
135
  body: form
136
136
  });
137
137
  });
@@ -140,7 +140,7 @@ export class Field<T extends FieldValue> {
140
140
  await this.record.layout.database.apiRequest<null>(`${this.record.endpoint}/containers/${this.id}/1`, {
141
141
  method: "POST",
142
142
  // @ts-ignore
143
- headers: {"Authorization": "Bearer " + this.record.layout.database.token, "Content-Type": "multipart/form-data"},
143
+ headers: {"content-type": "multipart/form-data"},
144
144
  body: form
145
145
  })
146
146
  }