lemmy-js-client icon indicating copy to clipboard operation
lemmy-js-client copied to clipboard

Getting Error: Not Found when using 0.20.0-inbox-combined.1

Open kingthrillgore opened this issue 1 year ago • 2 comments

Using the latest version on npm and when I attempt to run the example in the readme, it dies from a Not Found error. Was there a change in the Lemmy API recently or am I missing something?

PS E:\lemmy_image_downloader_ts\build> node .\test.js
Running script
E:\lemmy_image_downloader_ts\node_modules\.pnpm\[email protected]\node_modules\lemmy-js-client\dist\http.js:1158
            throw new Error(response.statusText);
                  ^

Error: Not Found
    at LemmyHttp.<anonymous> (E:\lemmy_image_downloader_ts\node_modules\.pnpm\[email protected]\node_modules\lemmy-js-client\dist\http.js:1158:19)
    at Generator.throw (<anonymous>)
    at rejected (E:\lemmy_image_downloader_ts\node_modules\.pnpm\[email protected]\node_modules\lemmy-js-client\dist\http.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.12.2
PS E:\lemmy_image_downloader_ts\build>

Compiled TS follows

import { LemmyHttp, Login } from "lemmy-js-client";

console.log("Running script");

// Build the client
const baseUrl = "https://lemmy.ml";
const client: LemmyHttp = new LemmyHttp(baseUrl);

// Build the login form
const loginForm: Login = {
  username_or_email: "<EMPTY>",
  password: "<EMPTY>",
};

// Login and set the client headers with your jwt
const { jwt } = await client.login(loginForm);
client.setHeaders({ Authorization: `Bearer ${jwt}` });

console.log(jwt);

// Fetch top posts for the day
// Commented out as GetPosts doesn't exist here
/* const getPostsForm: GetPosts = {
  sort: "TopDay",
  type_: "Local",
};
const posts = await client.getPosts(getPostsForm); */

kingthrillgore avatar Jan 18 '25 01:01 kingthrillgore

Are you running with a Lemmy 0.20 backend? Because there are many breaking changes compared to 0.19

Nutomic avatar Jan 20 '25 09:01 Nutomic

That's an experimental unreleased lemmy-js-client, are you working on developing something? Because you shouldn't be using unreleased versions otherwise.

dessalines avatar Jan 20 '25 21:01 dessalines