22 lines
1004 B
JavaScript
22 lines
1004 B
JavaScript
const BASE = "http://localhost:8090";
|
|
const login = await (await fetch(BASE + "/api/v1/auth/login", {
|
|
method: "POST", headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ account: "root", password: "root" }),
|
|
})).json();
|
|
const tok = login.access_token;
|
|
|
|
async function raw(method, path, body) {
|
|
const res = await fetch(BASE + path, {
|
|
method, headers: { "Content-Type": "application/json", Authorization: "Bearer " + tok },
|
|
body: body ? JSON.stringify(body) : undefined,
|
|
});
|
|
const text = await res.text();
|
|
console.log(method, path, "=>", res.status, text.slice(0, 200));
|
|
}
|
|
|
|
await raw("POST", "/api/v1/auth/favorites", { target_type: "runway", target_uid: "r0042h1mx", title: "t", cover: "c", brand: "b" });
|
|
await raw("POST", "/api/v1/auth/history", { target_uid: "r0042h1mx" });
|
|
await raw("POST", "/api/v1/auth/history", { target_uid: "r0042h1mx", extra: 1 });
|
|
await raw("POST", "/api/v1/auth/history", JSON.stringify({ target_uid: "r0042h1mx" }));
|
|
process.exit(0);
|