mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Format *.ts, *.js, *.css, *.html, *.json and *.svelte
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
+11
-8
@@ -25,8 +25,8 @@ export class Request {
|
||||
const urlString = this.createUrl(search);
|
||||
|
||||
return await Request.exec(urlString, {
|
||||
method: 'GET',
|
||||
headers: { ...headers, 'Accept': 'application/json' }
|
||||
method: "GET",
|
||||
headers: { ...headers, Accept: "application/json" },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ export class Request {
|
||||
const urlString = this.createUrl();
|
||||
|
||||
return await Request.exec(urlString, {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
headers: { ...headers, 'Content-Type': 'application/json' }
|
||||
headers: { ...headers, "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,14 +52,17 @@ export class Request {
|
||||
const urlString = this.createUrl();
|
||||
|
||||
return await Request.exec(urlString, {
|
||||
method: 'PUT',
|
||||
method: "PUT",
|
||||
body: JSON.stringify(body),
|
||||
headers: { ...headers, 'Content-Type': 'application/json' }
|
||||
headers: { ...headers, "Content-Type": "application/json" },
|
||||
});
|
||||
}
|
||||
|
||||
// Executes a request and returns the response.
|
||||
static async exec(urlString: string, props: Record<string, any>): Promise<any> {
|
||||
static async exec(
|
||||
urlString: string,
|
||||
props: Record<string, any>,
|
||||
): Promise<any> {
|
||||
let response = null;
|
||||
try {
|
||||
response = await fetch(urlString, props);
|
||||
@@ -67,7 +70,7 @@ export class Request {
|
||||
throw new ApiError("API request failed", urlString);
|
||||
}
|
||||
|
||||
if (! response.ok) {
|
||||
if (!response.ok) {
|
||||
throw new ApiError(response.statusText, urlString);
|
||||
}
|
||||
return response.json();
|
||||
|
||||
Reference in New Issue
Block a user