mutipart
This commit is contained in:
@@ -406,8 +406,10 @@ export class ApiClient {
|
||||
const headers = { ...extraHeaders };
|
||||
let payload;
|
||||
if (body !== undefined) {
|
||||
if (raw) {
|
||||
headers['Content-Type'] = contentType;
|
||||
if (typeof FormData !== 'undefined' && body instanceof FormData) {
|
||||
payload = body;
|
||||
} else if (raw) {
|
||||
if (contentType) headers['Content-Type'] = contentType;
|
||||
payload = body;
|
||||
} else {
|
||||
headers['Content-Type'] = contentType || 'application/json';
|
||||
|
||||
@@ -20,7 +20,11 @@ function readableHeaders(headers) {
|
||||
}
|
||||
|
||||
async function http(path, { method = 'GET', body } = {}) {
|
||||
const headers = { 'Content-Type': 'application/json' };
|
||||
const isFormData = typeof FormData !== 'undefined' && body instanceof FormData;
|
||||
const headers = {};
|
||||
if (!isFormData) {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
const url = new URL(path, window.location.origin).href;
|
||||
|
||||
logApi('request', {
|
||||
@@ -38,7 +42,7 @@ async function http(path, { method = 'GET', body } = {}) {
|
||||
method,
|
||||
headers,
|
||||
credentials: 'include',
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
body: isFormData ? body : (body ? JSON.stringify(body) : undefined),
|
||||
});
|
||||
|
||||
const responseHeaders = readableHeaders(res.headers);
|
||||
|
||||
Reference in New Issue
Block a user