sync working code, and import type-doc
This commit is contained in:
@ -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]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user