1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export async function getLemmyJwt({ instance, username, password }: {
instance: string;
username: string;
password: string;
}) {
//const { LemmyHttp } = await import("npm:lemmy-js-client");
const { LemmyHttp } = await import("npm:lemmy-js-client@0.18.1");
let client = new LemmyHttp(`https://${instance}`, {
fetchFunction: fetch,
});
try {
const ret = await client.login({
username_or_email: username,
password: password,
});
console.info(ret);
return ret.jwt;
}
catch (e) {
console.info("Unable to obtain token from server.");
console.error("Error", e.stack);
console.error("Error", e.name);
console.error("Error", e.message);
}
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023