install prettier

This commit is contained in:
mProjectsCode 2022-10-25 16:45:36 +02:00
parent 2662c78080
commit 9e2961421d
57 changed files with 2367 additions and 1162 deletions

View file

@ -1,32 +1,32 @@
import { RequestUrlParam, RequestUrlResponse } from "obsidian";
import { RequestUrlParam, RequestUrlResponse } from 'obsidian';
export function requestUrl(request: RequestUrlParam): Promise<RequestUrlResponse> {
return fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
}).then(async (response) => {
if (response.status >= 400 && request.throw) {
throw new Error(`Request failed, ${response.status}`);
}
return fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
}).then(async response => {
if (response.status >= 400 && request.throw) {
throw new Error(`Request failed, ${response.status}`);
}
// Turn response headers into Record<string, string> object
const headers: Record<string, string> = {};
response.headers.forEach((value, key) => {
headers[key] = value;
});
// Turn response headers into Record<string, string> object
const headers: Record<string, string> = {};
response.headers.forEach((value, key) => {
headers[key] = value;
});
const arraybuffer = await response.arrayBuffer();
const text = arraybuffer ? new TextDecoder().decode(arraybuffer) : '';
const json = text ? JSON.parse(text) : {};
const arraybuffer = await response.arrayBuffer();
const text = arraybuffer ? new TextDecoder().decode(arraybuffer) : '';
const json = text ? JSON.parse(text) : {};
let response_body: RequestUrlResponse = {
status: response.status,
headers: headers,
arrayBuffer: arraybuffer,
json: json,
text: text,
};
return response_body;
});
}
let response_body: RequestUrlResponse = {
status: response.status,
headers: headers,
arrayBuffer: arraybuffer,
json: json,
text: text,
};
return response_body;
});
}