sync working code, and import type-doc

This commit is contained in:
2023-07-17 17:24:49 +08:00
parent 7ab7a7094a
commit 3e9ee59178
43 changed files with 1024 additions and 1553 deletions

View File

@ -12,9 +12,10 @@ function get(url, options = {}) {
return fetch(combineUrl(url), {
method: options.method || 'GET',
headers: {
...options.customerHeaders,
'Accept': options.accept || 'application/json'
...options.customHeaders,
'Accept': options.accept ?? 'application/json'
},
mode: options.mode,
signal: options.signal,
cache: 'default'
});
@ -29,16 +30,16 @@ function post(url, data, options = {}) {
data = JSON.stringify(data);
}
// contentType = 'application/json';
if (options.customerHeaders == null) {
options.customerHeaders = {};
if (options.customHeaders == null) {
options.customHeaders = {};
}
if (options.customerHeaders['Content-Type'] == null) {
options.customerHeaders['Content-Type'] = 'application/json';
if (options.customHeaders['Content-Type'] == null) {
options.customHeaders['Content-Type'] = 'application/json';
}
}
return fetch(combineUrl(url), {
method: options.method || 'POST',
headers: options.customerHeaders,
headers: options.customHeaders,
body: data,
signal: options.signal,
cache: 'no-cache'
@ -65,8 +66,8 @@ function upload(url, data, options = {}) {
}, false);
}
request.open('POST', combineUrl(url));
if (options.customerHeaders != null) {
for (let header of Object.entries(options.customerHeaders)) {
if (options.customHeaders != null) {
for (let header of Object.entries(options.customHeaders)) {
request.setRequestHeader(header[0], header[1]);
}
}