chore: add prettier frontent linter

This commit is contained in:
Oleg Lobanov
2021-03-21 12:51:58 +01:00
parent a721dc1f31
commit c44b37c50c
73 changed files with 18898 additions and 4499 deletions

View File

@@ -1,52 +1,51 @@
import { fetchURL, fetchJSON } from './utils'
import { fetchURL, fetchJSON } from "./utils";
export async function getAll () {
return fetchJSON(`/api/users`, {})
export async function getAll() {
return fetchJSON(`/api/users`, {});
}
export async function get (id) {
return fetchJSON(`/api/users/${id}`, {})
export async function get(id) {
return fetchJSON(`/api/users/${id}`, {});
}
export async function create (user) {
export async function create(user) {
const res = await fetchURL(`/api/users`, {
method: 'POST',
method: "POST",
body: JSON.stringify({
what: 'user',
what: "user",
which: [],
data: user
})
})
data: user,
}),
});
if (res.status === 201) {
return res.headers.get('Location')
return res.headers.get("Location");
} else {
throw new Error(res.status)
throw new Error(res.status);
}
}
export async function update (user, which = ['all']) {
export async function update(user, which = ["all"]) {
const res = await fetchURL(`/api/users/${user.id}`, {
method: 'PUT',
method: "PUT",
body: JSON.stringify({
what: 'user',
what: "user",
which: which,
data: user
})
})
data: user,
}),
});
if (res.status !== 200) {
throw new Error(res.status)
throw new Error(res.status);
}
}
export async function remove (id) {
export async function remove(id) {
const res = await fetchURL(`/api/users/${id}`, {
method: 'DELETE'
})
method: "DELETE",
});
if (res.status !== 200) {
throw new Error(res.status)
throw new Error(res.status);
}
}